[Year 12 SofDev] Arrays with mixed data types
timmer at westnet.com.au
timmer at westnet.com.au
Fri Jun 12 17:48:13 AEST 2015
Hello Mark
From memory arrays in PHP are not true arrays but associative
arrays; that is a set of key:value pairs (what some languages call a
dictionary). From the syntax point of view they look like arrays in
that the key can be an integer, hence a[3]=543, and becuase they are
key:value pairs, the next item can be a[4] = "text".
What I'm calling a "true array" only has values stored in memory and
the location of a particular element is calculated via the index, the
calcuation being dependent on the type of element stored in the array,
hence it must be of fixed size, hence of fixed data type. Elements in
so called associative arrays are located by searching the key list.
This means that "indexes" don't have to be contiguous, and don't even
have to be integers. In some ways they are more like Pascal's records.
Associative arrays get interesting when you move into
multi-dimensions. Elements in true 2D array can be imagined to be in a
rectangular block with the row and column indexes being use to
determine the location of any one element; a[1,2] etc. In some
ways, a 2D associative array are best visualised as a set of arrays
within an array. The first 'index' locates the 'row' (or maybe
'column') of elements (a linear 'array'), and the second 'index'
locates the required element with in the row/column; hence the syntac
often (always?) used: a[1][2].
Regards
Robert T-A
----- Original Message -----
From: "Year 12 Software Development Teachers' Mailing List"
To:"Year 12 Software Development Teachers' Mailing List"
Cc:
Sent:Fri, 12 Jun 2015 14:25:58 +1000
Subject:Re: [Year 12 SofDev] Arrays with mixed data types
I'm not familiar with the inner workings of PHP, but my research
suggests their 'arrays' are not exactly the same nature as most other
languages.
It's sort of like when TV guides categorise 'Big Brother' as
'entertainment' ... a non-classical use of the term.
I ask because I'm writing an exam with a question about whether a 2D
array with mixed data types is possible (or wise).
Cheers Mark
On 12 June 2015 at 14:09, Laurie Savage wrote:
If it quacks like an array ...? Could you elaborate on why Python
lists ain't arrayz?
Laurie
Laurie Savage
https://sites.google.com/a/pvgc.vic.edu.au/mr-savage/home [2]
On 12 June 2015 at 13:27, Mark wrote:
Hi, codemakers.
Most languages require all elements of an array to have a single data
type, but I have a nagging suspicion that there is an exception or
two.
e.g. Apparently PHP allows mixed data types in its 'arrays' but I
believe PHP 'arrays' are actually more like the lists found in Perl or
Python and so are not classical arrays.
Is there a language that allows true arrays with mixed data types?
Cheers Mark
--
Before Facebook, how many people would take a picture of their
dinner on a disposable camera, get the photos developed, then go round
to your friends' houses and show them all the photo?
--
Mark Kelly
http://vceit.com [4]
_______________________________________________
http://www.edulists.com.au [5] - FAQ, Subscribe, Unsubscribe
IT Software Development Mailing List kindly supported by
http://www.vcaa.vic.edu.au [6] - Victorian Curriculum and Assessment
Authority and
http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
[7]
http://www.vitta.org.au [8] - VITTA Victorian Information Technology
Teachers Association Inc
http://www.swinburne.edu.au/ict/schools [9] - Swinburne University
_______________________________________________
http://www.edulists.com.au [10] - FAQ, Subscribe, Unsubscribe
IT Software Development Mailing List kindly supported by
http://www.vcaa.vic.edu.au [11] - Victorian Curriculum and Assessment
Authority and
http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
[12]
http://www.vitta.org.au [13] - VITTA Victorian Information
Technology Teachers Association Inc
http://www.swinburne.edu.au/ict/schools [14] - Swinburne University
--
>> Witty sig goes HERE
Links:
------
[1] mailto:08327998 at pvgc.vic.edu.au
[2] https://sites.google.com/a/pvgc.vic.edu.au/mr-savage/home
[3] mailto:mark at vceit.com
[4] http://vceit.com
[5] http://www.edulists.com.au
[6] http://www.vcaa.vic.edu.au
[7]
http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
[8] http://www.vitta.org.au
[9] http://www.swinburne.edu.au/ict/schools
[10] http://www.edulists.com.au
[11] http://www.vcaa.vic.edu.au
[12]
http://www.vcaa.vic.edu.au/vce/studies/infotech/softwaredevel3-4.html
[13] http://www.vitta.org.au
[14] http://www.swinburne.edu.au/ict/schools
[15] http://vceit.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.edulists.com.au/pipermail/sofdev/attachments/20150612/a41e0f39/attachment.html
More information about the sofdev
mailing list