A few holiday thoughts on arrays...
Coming from a non-programmer background, I found arrays rather
intimidating until I began to realize how similar they are to everyday items:
One-dimensional array: like a numbered list.
Two-dimensional array: like a spreadsheet or table with cell references based on row
and
column.
Three-dimensional array: like a cube with cell references based on 3 dimensions.
Of course, I know that in CF, arrays are dynamic -- each "row" of a 2 dimensional
array can be a different length. A 2-dim array is really just a one-dimensional array
where each cell is occupied by a one-dimensional array of any length.
Although I've often heard it said that it's difficult to visualize arrays of more than
3-dimensions, I wonder if a game we used to play as children might help....It was
called
Quad, and was basically a multi-tiered Tic-Tac-Toe game -- multiple levels of rows and
columns. So, ignoring the fact that CF arrays don't necessarily have the same number
of
elements in each dimension, I'd be interested in feedback on whether the following
models accurately portray complex arrays:
Three-dimensional array: Like a "Quad" game. Example: MyArray[2][3][1] means the data
that's stored on the second level of the game, third row and first column.
Four-dimensional array: Like a single-file lineup of Quad games. MyArray[5][2][3][1]
means the data that's stored on the fifth game in the lineup, second level, third row
and first column.
Five-dimensional array: Like a big checkboard with a Quad game sitting on each square.
MyArray[4][5][2][3][1] means the data that's stored in the game that's sitting on the
fourth row and fifth column of the checkerboard, and on that game, the data is in the
second level, third row and first column.
Six-dimensional array: Like a huge Quad game, with each square occupied by a Quad game
of
its own. MyArray[2][4][5][2][3][1] means the data that's stored in the game found on
the
second level, fourth row and fifth column of the huge Quad game, and on
that game, the data is in the second level, third row and first column.
I could keep going... 7 dimensions would be like a string of huge quad games, with
each
of the huge quad games having each of their cells occuped by a Quad game...Seems like
you
could keep going forever...
Accurate depiction? Next question: When would you need a 7-dimension array?
Gene Kraybill
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.