<br>On 19 August 2010 20:53, Janson, Adrian A <<a href="mailto:janson.adrian.a@edumail.vic.gov.au">janson.adrian.a@edumail.vic.gov.au</a>> wrote:<br>> A one dimensional (or 1D) array is a data structure in which variables are grouped together under the same name...<br>
<br>I see a couple of problems with this definition. First, an array can group together things which are not variables, i.e. literals, e.g. in Python:<br><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">>>> foo = [1, 1, 2, 3, 5, 8, 13, 21]</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">>>> bar = ["no", "variables", "here!"]</span><br style="font-family: courier new,monospace;"><br>Second, an array is an array even if it doesn't have a name, e.g. in Python:<br>
<br><span style="font-family: courier new,monospace;">>>> my_function(["I", "don't", "have", "a", "name"])</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">>>> ["indexing", "a", "literal", "array"][2]</span><br><br>> A record is a structure that can be used to group together variables for a particular purpose.<br>
<br>This definitions shares the first problem above, but it also brings in something extraneous: "for a particular purpose". Surely any data structure serves some particular purpose intended for it by a programmer.<br>
<br>> Indexing the elements of a record is often done via an identifier which is declared at the same time as the record.<br><br>This is true when the record is implemented as an associative array, but not when it is represented as a tuple. E.g. in Python:<br>
<br><span style="font-family: courier new,monospace;">>>> array_of_tuples = [(1441412050, 'Alice in Wonderland', 'Lewis Carroll'),<br>... (</span><span style="font-family: courier new,monospace;">1441412341, 'Through the Looking Glass', </span><span style="font-family: courier new,monospace;">'Lewis Carroll')]<br>
>>> print array_of_tuples[1][2]<br>Lewis Carroll<br><br></span>Here we accessed an element of a record using an integer. But you're probably ok here since you said "often", and I agree with that.<br>
<br>-Steven Bird<br><br>