ARRAY _ _ _ _ _ _ _ _ _ _ _ _ declaration
The array declaration declares a list of identifiers to be of type array, and sets all their entries to 0.
array<identifier>(<dimensions>) {,<identifier>(<dimensions>)}*
<identifier> may be any valid REDUCE identifier. If the identifier was already an array, a warning message is given that the array has been redefined. <dimensions> are of form <integer>{,<integer>}*.
array a(2,5),b(3,3,3),c(200); array a(3,5); *** ARRAY A REDEFINED a(3,4); 0 length a; {4,6}
Arrays are always global, even if defined inside a procedure or bl ock statement. Their status as an array remains until the variable is reset by clear. Arrays may not have the same names as operators , procedures or scalar variables.
Array elements are referred to by the usual notation: a(i,j) returns the jth element of the ith row. The assignment operator := is used to put values into the array. Arrays as a whole cannot be subject to assignment by let or := ; the assignment operator := is only valid for individual elements.
When you use let on an array element, the contents of that element become the argument to let. Thus, if the element contains a number or some other expression that is not a valid argument for this command, you get an error message. If the element contains an identifier, the identifier has the substitution rule attached to it globally. The same behavior occurs with clear. If the array element contains an identifier or simple_expression, it is cleared. Do <not> use clear to try to set an array element to 0. Because of the side effects of either let or clear, it is unwise to apply either of these to array elements.
Array indices always start with 0, so that the declaration array a(5) sets aside 6 units of space, indexed from 0 through 5, and initializes them to 0. The length command returns a list of the true number of elements in each dimension.