Where a 2D array has two indices, and you specify them both at once to pick out the element you want, an array of arrays has one index into each array.
Two dimensional array:
type MAT45 is array (1 .. 4, 1 .. 5) of INTEGER; R : MAT45;
Array of arrays:
type ROW5 is array (1 .. 5) of INTEGER; type MATRIX35 is array (1 .. 3) of ROW5; X : MATRIX35;
An array of STRINGs is a special case of arrays of arrays:
subtype NAMES is STRING (1 .. 20); type REGISTERS is array (POSITIVE range <>) of NAMES;
To refer to an element of an array of arrays, you must specify indexes separately
X(2) entire second row of array X X(2)(3) a single element of row 2 of X
Note the difference from 2D matrix reference.
Advantages of arrays of arrays
X(2)
X(2..3)
means rows 2 and 3
X(2..3)(1)
means 1st item of rows 2 and 3
X(4)(2..4)
means items 2,3,4 of row 4
Disadvantages of arrays of arrays
type ROW5 is array (1 .. 5) of INTEGER; type MATRIXN5 is array (POSITIVE range <>) of ROW5;