Go to the first, previous, next, last section, table of contents.


Vectors

A vector is a fixed-size sequence of Lisp objects, each element may be accessed in constant time -- unlike lists where the time taken to access an element is proportional to the position of the element.

The read syntax of a vector is an opening square bracket, followed by zero or more space-separated objects, followed by a closing square bracket. For example,

[zero one two three]

In general it is best to use vectors when the number of elements to be stored is known and lists when the sequence must be more dynamic.

Function: vectorp object
This function returns t if its argument, object, is a vector.

Function: vector &rest elements
This function creates a new vector containing the arguments given to the function.

(vector 1 2 3)
    => [1 2 3]

(vector)
    => []

Function: make-vector size &optional initial-value
Returns a new vector, size elements big. If initial-value is defined each element of the new vector is set to initial-value, otherwise they are all nil.

(make-vector 4)
    => [nil nil nil nil]

(make-vector 2 t)
    => [t t]


Go to the first, previous, next, last section, table of contents.