Extensions |
number array:at ( number i1, i2, ... in )
Returns the value at the calculated n-dimensional index given by i1, i2, ... in. The number of indexes must match the dimensionality originally specified in array.new() or the last call to resize(). There is no bounds checking provided on the individual indexes. The value parameter must be the last parameter, after the variable number of index parameters.
Given dimensions of size d1, d2, ... dn, and indexes i1, i2, ... in, then the index is calculated as:
idx = [(d2 * d3 * ... * dn) * i1] + [(d3 * d4 * ... * dn) * i2] + ... + (dn * in-1) + in
For a 3-dimensional array then, the calculated index would be:
idx = [(d2 * d3) * i1] + (d3 * i2) + i3
Parameters
in | One or more array indexes matching the dimensionality of the array |
Return Values
number | Value at the calculated index |
Example
Copyright 2010 Justin Aquadro