2.12 Vectors

Lists enable access of items of a linear collection by position number using the function nth; however, this access is inefficient if used frequently because for every access the sequence of pairs has to be traversed until the desired object is reached. An alternative structure for direct access by element number in symbolic mode is the vector. The first element in a vector has the index 0.

v:=mkvect(n)create a vector of length n
putv(v,m,u)put value u into mth slot of vector v
getv(v,m)extract element m from vector v
upbv(v)returns upper bound for v

Note that putv is a “destructive” operation.