indices
This page describes how to access the bounds and indices for arrays. See also Define a Generator for information about generators.
For an array a, the a.indices() operator results in a generator for the array's indices. For example, for one, two, and three dimensional arrays a, b, and c:
Use seq(array.indices()) to get deterministic indexing.
Note: As per Trac #4, array.indices() only works if you use parentheses. The form
presented in the language specification does not work. When Trac #4 is fixed, the parenthesized form will no longer work.
bounds
a.bounds() yields a Range of the array bounds. You can use this to create specific generators or specific indexing. For example:
For a two dimensional array, the value returned by bounds() is a Range[\(ZZ32,ZZ32)\]. Actually, to be very specific it is a Tuple2Range[\ZZ32,ZZ32\].
The will also work
To access the upper bound for dimensions 0 and 1 of a two dimensional array b, use (u0,u1) = b.bounds().upper()
If you only want one, you can use _ to ignore the other one in the tuple binding: (u0,_) = b.bounds().upper()
indexValuePairs
array.indexValuePairs() is a generator for both the indices and the corresponding array value:
Sadly, you can't (yet) nest tuple bindings so it's actually a bit clunky for arrays of two or more dimensions. That is, you can't do
In general, bounds yield a Range describing how big your array is, but indices returns a generator that actually follows the structure of the array itself. For example for a sparse matrix indices() yields only the defined indices whereas bounds() yields every index.

