next up previous

4.2 Array Sections     continued...

Returning to the more general form of vector subscripts, though the above examples employ array constructors, any one-dimensional array expression is permitted. The only requirement is that the value of each element of the vector subscript be a valid subscript value for that dimension. A common form for vector subscripts is a one-dimensional integer array name (or section), whose element values have been previously established. This form is extremely useful for indirect access, such as indexing into a table; e.g., table elements may be retrieved (or set) by subscripting the table array with an array containing the desired table index values.

A couple of final examples will complete this introduction to array sections. Again, for purposes of explicitness, array constructors will be used, but in practice more concise one-dimensional array names or sections are more likely. First, an array section need not be as easily depictable graphically as the examples above. For the array defined above, consider the section

Q((/2,5,3/),(/6,4/))
This represents the array section

This section can be used in any array expression in which a 3x2 array object is valid. It may also appear on the left hand side of an array assignment, in which case the (1,1) element of the right hand side expression value gets assigned to , the (3,2) value of the right hand side gets assigned to , and so on.