Next: Cutting Vectors, Previous: Construction of Vectors, Up: Vectors [Contents][Index]
Returns #t if object is a vector; otherwise returns
#f.
Returns the number of elements in vector.
Returns the contents of element k of vector. K must be a valid index of vector.
(vector-ref '#(1 1 2 3 5 8 13 21) 5) ⇒ 8
Stores object in element k of vector and returns an unspecified value. K must be a valid index of vector.
(let ((vec (vector 0 '(2 2 2 2) "Anna")))
  (vector-set! vec 1 '("Sue" "Sue"))
  vec)
     ⇒  #(0 ("Sue" "Sue") "Anna")
These procedures access the first several elements of vector in the obvious way. It is an error if the implicit index of one of these procedurs is not a valid index of vector.
Searches vector for an element with a key matching key,
returning the element if one is found or #f if none.  The
search operation takes time proportional to the logarithm of the length
of vector.  Unwrap-key must be a procedure that maps each
element of vector to 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
Next: Cutting Vectors, Previous: Construction of Vectors, Up: Vectors [Contents][Index]