Vectors

In data representation it is often natural to make the serially ordered sets presented as a vector of data objects. It is possible to refer to vector units through their layout, nothing knowing about units. On the other hand, it is possible to subject the data items presented in the form of a vector simply to uniform operations on the basis of their content, for example such, as deleting of certain units from set, set marshaling by any criterion and so on.
Vectors like lists contain lisp objects, such as atoms, numbers, lists or other vectors. The external form of representation of vectors is

#(x1 x2 … xn) ; n-element vector

It is possible to access to vector units effectively directly, to select and assign it values, setting unit number.

The main operations with vectors

The vector can be created by means of function

('vector newobject quantity [initial-element])

>('oh set ('vector newobject 4 'oh))
#(oh oh oh oh)

Also it is possible to create a matrix, setting its dimension:

>('m set ('vector newobject '(3 4) 0))
#(#(0 0 0 0) #(0 0 0 0) #(0 0 0 0))

It is possible to refer to a new unit a call:

(vector elt n)

>(oh elt 0) ; indexing starts with zero
oh

The matrix unit can be received so:

(matrix elt x y)

>(m elt 1 2)
0

To change a unit, assignment function setelt is used:

>(oh setelt 0 'oy)
#(oy oh oh oh)
>(m setelt 1 2 7)
#(#(0 0 0 0) #(0 0 7 0) #(0 0 0 0))

The vector part can be constructed call:

(vector subseq beginning [the-end])

>(oh subseq 0 2)
#(oy oh)

Besides, for vectors many functions mentioned in connection with operation over lists, it - size, reverse and remove are generalised:

>(#(a b c) reverse)
#(c b a)
>(#(a b b a) remove 'a)
#(b b)