Vectors are heterogenous structures whose elements are indexed by integers. A vector typically occupies less space than a list of the same length, and the average time required to access a randomly chosen element is typically less for the vector than for the list.

The *length* of a vector is the number of elements that it
contains. This number is a non-negative integer that is fixed when the
vector is created. The *valid indexes* of a
vector are the exact non-negative integers less than the length of the
vector. The first element in a vector is indexed by zero, and the last
element is indexed by one less than the length of the vector.

Vectors are written using the notation `#(``obj`` ...)`.
For example, a vector of length 3 containing the number zero in element
0, the list (2 2 2 2) in element 1, and the string "Anna" in
element 2 can be written as following:

#(0 (2 2 2 2) "Anna")

Note that this is the external representation of a vector, not an expression evaluating to a vector. Like list constants, vector constants must be quoted:

'#(0 (2 2 2 2) "Anna") ==> #(0 (2 2 2 2) "Anna")

— procedure: **make-vector**` k`

— procedure:**make-vector**` k fill`

— procedure:

Returns a newly allocated vector of

kelements. If a second argument is given, then each element is initialized tofill. Otherwise the initial contents of each element is unspecified.

— library procedure: **vector**` obj ...`

Returns a newly allocated vector whose elements contain the given arguments. Analogous to list.

(vector 'a 'b 'c) ==> #(a b c)

— procedure: **vector-ref**` vector k`

kmust be a valid index ofvector. Vector-ref returns the contents of elementkofvector.(vector-ref '#(1 1 2 3 5 8 13 21) 5) ==> 8 (vector-ref '#(1 1 2 3 5 8 13 21) (let ((i (round (* 2 (acos -1))))) (if (inexact? i) (inexact->exact i) i))) ==> 13

— procedure: **vector-set!**` vector k obj`

kmust be a valid index ofvector. Vector-set! storesobjin elementkofvector. The value returned by vector-set! is unspecified.(let ((vec (vector 0 '(2 2 2 2) "Anna"))) (vector-set! vec 1 '("Sue" "Sue")) vec) ==> #(0 ("Sue" "Sue") "Anna") (vector-set! '#(0 1 2) 1 "doe") ==>error; constant vector

— library procedure: **vector->list**` vector`

— library procedure:**list->vector**` list`

— library procedure:

Vector->list returns a newly allocated list of the objects contained in the elements of

vector. List->vector returns a newly created vector initialized to the elements of the listlist.(vector->list '#(dah dah didah)) ==> (dah dah didah) (list->vector '(dididit dah)) ==> #(dididit dah)