(ARRAY number list)
(ARRAY list list)
|Explanation||ARRAY creates an array of the size
specified by its input. If the input is a number, a
one-dimensional array of the specified size is created.
Its elements may be accessed by numbers between 0 and the
input size less 1.
If the input to ARRAY is a list, the list describes the array. Each number in the list corresponds to the size of one dimension of the array. In order to access an element of a multi-dimensional array, a list of numbers must be supplied to the AGET and ASET primitives, where each number must be in the range from 0 to the number supplied for the corresponding dimension less 1.
A list may be supplied as an optional second element if ARRAY and all its arguments are enclosed in parentheses. The contents of this list are the initial values of the array elements.
|Examples||MAKE "A ARRAY [2 2]
ASET :A [1 0] [HELLO WORLD]
AGET :A [1 0]
Result: [HELLO WORLD]
AGET :A [0 0]
AGET :A [2 0]
2 is not inside the allowed range of 0 to 1 for dimension 1