next up previous contents
Next: Reduction operators Up: Vectors and vector operators Previous: Vectors as inputs and   Contents

Iteratively constructing vectors

A vector may be constructed iteratively using the construction [f(i):i=l..r], where f(i) is some expression containing the parameter i, and l, r are integers. This expands to the vector [f(l),...,f(r)]. For example, the expression:

        [ i*i : i = 1..5 ]
is equivalent to:
        [1,4,9,16,25]
On the other hand:
        [ i*i : i = 5..1 ]
is equivalent to:
        [25,16,9,4,1]



2002-10-28