Next: Cutting Vectors, Previous: Construction of Vectors, Up: Vectors

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

Returns the contents of element

kofvector.Kmust be a valid index ofvector.(vector-ref '#(1 1 2 3 5 8 13 21) 5) => 8

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

Stores

objectin elementkofvectorand returns an unspecified value.Kmust be a valid index ofvector.(let ((vec (vector 0 '(2 2 2 2) "Anna"))) (vector-set! vec 1 '("Sue" "Sue")) vec) => #(0 ("Sue" "Sue") "Anna")

— procedure: **vector-first**` vector`

— procedure:**vector-second**` vector`

— procedure:**vector-third**` vector`

— procedure:**vector-fourth**` vector`

— procedure:**vector-fifth**` vector`

— procedure:**vector-sixth**` vector`

— procedure:**vector-seventh**` vector`

— procedure:**vector-eighth**` vector`

— procedure:

— procedure:

— procedure:

— procedure:

— procedure:

— procedure:

— procedure:

These procedures access the first several elements of

vectorin the obvious way. It is an error if the implicit index of one of these procedurs is not a valid index ofvector.

— procedure: **vector-binary-search**` vector key<? unwrap-key key`

Searches

vectorfor an element with a key matchingkey, returning the element if one is found or`#f`

if none. The search operation takes time proportional to the logarithm of the length ofvector.Unwrap-keymust be a procedure that maps each element ofvectorto a key.Key<?must be a procedure that implements a total ordering on the keys of the elements.(define (translate number) (vector-binary-search '#((1 . i) (2 . ii) (3 . iii) (6 . vi)) < car number)) (translate 2) => (2 . ii) (translate 4) => #F