Composed objects: rows

In Elan-0 the only composed objects are (one-dimensional) row-variables and row-constants. A declaration for a row-variable looks like


\begin{literal}
{\tt ROW 5 INT VAR weight}
{\tt \vert \vert \vert \vert\_\_\...
...}type of each element
{\tt \vert\_\_\_\_\_\_}number of elements
\end{literal}

After this declaration, the row-variable weight has 5 elements, numbered from 1 to 5. Each element has an (as yet undefined) value of the type INT.

The subscription


\begin{elan}
row [ i ]
\end{elan}

denotes its i-th element provided the value of the expression i (the index) is between one and the number of elements. A subscription of a row-variable has the access attribute VAR, so it can be assigned to, e.g.


\begin{elan}
weight [ i ] := 144
\end{elan}

After this assignment, the element whose index is equal to the value of i, which must be in the range 1 to 5, is equal to 144. Similarly, a row-constant can be declared like


\begin{elan}
ROW 5 INT CONST first 5 primes ::[ 2, 3, 5, 7, 11 ]
\end{elan}

The construct with the square brackets in this example is a row-display, which acts as a denotation for a row. As with other constant declarations, the initialization (with a row-display or another row) in a row-constant declaration is obligatory. A subscription from a row-constant has the access attribute CONST, so it can not be assigned to.

Apart from the possibility of manipulating individual elements of a row, it is also possible to deal with the row as a whole, e.g. in the assignment


\begin{elan}
weight := first 5 primes
\end{elan}

In assignments and initializations, the number of elements in the left and right hand side must match. The elements of a row can in their turn be rows again, with a declaration like


\begin{elan}
ROW 10 ROW 20 INT table
\end{elan}

and a subscription like


\begin{elan}
table [ i ][ j + 1 ]
\end{elan}

provided, of course, that 1 <= i <= 10 and 1 <= j + 1 <= 20.