{"id":5096,"date":"2014-08-01T10:23:26","date_gmt":"2014-08-01T10:23:26","guid":{"rendered":"http:\/\/www.oracletutoring.ca\/blog\/?p=5096"},"modified":"2014-08-01T10:23:26","modified_gmt":"2014-08-01T10:23:26","slug":"computer-science-what-is-an-array","status":"publish","type":"post","link":"https:\/\/www.oracletutoring.ca\/blog\/computer-science-what-is-an-array\/","title":{"rendered":"Computer Science:  what is an array?"},"content":{"rendered":"<h1>Returning to computer science, we continue our summer tutoring project surrounding PERL programming. \u00a0The tutor introduces the concept of an array &#8211; first, from a generic viewpoint.<\/h1>\n<p>Every computer programming language I know of uses the concept of an array.  Python, if I recall correctly, uses the term <em>list<\/em>.  Although a given computer language has its own flavour of it, the array is useful to preview from a generic point of view.<\/p>\n<p>Here&#8217;s an example of an array:  (&#8220;eggs&#8221;,&#8221;bread&#8221;,&#8221;milk&#8221;,&#8221;butter&#8221;,&#8221;jam&#8221;).  This array contains five pieces of information.  You could also say it contains five items.  However, computer science people would commonly say it contains five <em>values<\/em>.  Note that a value doesn&#8217;t have to be a number; it can also be a noun.<\/p>\n<p>One curiosity of arrays is that they start at 0:  in the array above, element 0 is &#8220;eggs&#8221;.  Element 1 is &#8220;bread&#8221;.  Therefore, &#8220;jam&#8221; is element 4, even though it&#8217;s in the fifth position.<\/p>\n<p>Perl has functions that remove or add values to an array, give its length, etc.  In Perl, the array above might be defined as follows:<\/p>\n<p><span style=\"font-family:monospace\">@groceries=(&#8220;eggs&#8221;,&#8221;bread&#8221;,&#8221;milk&#8221;,&#8221;butter&#8221;,&#8221;jam&#8221;);<\/span><\/p>\n<p>The @ symbol means it&#8217;s an array.  $groceries[0] is the zeroth element of @groceries, so $groceries[0] is &#8220;eggs&#8221;.  $groceries[3] is &#8220;butter&#8221;.<\/p>\n<p>For more about arrays, as well as programming in general, please return soon.  Hope you&#8217;re enjoying the season, wherever you are.  Here, the heat wave continues:)<\/p>\n<p>Jack of <a href=\"https:\/\/www.oracletutoring.ca\">Oracle Tutoring by Jack and Diane,<\/a> Campbell River, BC.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Returning to computer science, we continue our summer tutoring project surrounding PERL programming. \u00a0The tutor introduces the concept of an array &#8211; first, from a generic viewpoint. Every computer programming language I know of uses the concept of an array. &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/www.oracletutoring.ca\/blog\/computer-science-what-is-an-array\/\"> <span class=\"screen-reader-text\">Computer Science:  what is an array?<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[105],"tags":[191,173,106],"class_list":["post-5096","post","type-post","status-publish","format-standard","hentry","category-computer-science","tag-array","tag-perl-programming","tag-programming"],"_links":{"self":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/5096","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/comments?post=5096"}],"version-history":[{"count":21,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/5096\/revisions"}],"predecessor-version":[{"id":5117,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/posts\/5096\/revisions\/5117"}],"wp:attachment":[{"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/media?parent=5096"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/categories?post=5096"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.oracletutoring.ca\/blog\/wp-json\/wp\/v2\/tags?post=5096"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}