Access to Vectors

An element of a vector is accessed by specifying the vector and the index of the desired element.

(vector-ref vector i)
accesses the ith element of vector. i must be in the range 0 to k - 1, where k is the length of the vector.

(vector-set! vector i obj)
sets the ith element of vector to be obj.


> (define v1 '#(tom dick harry))
v1

> (vector-ref v1 1) dick

> (vector-set! v1 1 'jane) #(tom jane harry)

> (vector-ref v1 1) jane

Contents    Page-10    Prev    Next    Page+10    Index