Back to index A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Other

Alphabetic catalog of Language elements V

vector

vector creates a vector from its arguments.

Category Primitive procedure
Format (vector obj1 ...)
Parameters
objiany object
Description vector gathers its arguments into a vector and returns it.
R4RS Compliance Full
Examples
(vector 'a -3 "hello") => #(a -3 "hello")
(vector '()) => #(())
(vector) => #()

vector->list

vector->list converts a vector to a list.

Category Native procedure
Format (vector->list vec)
Parameters
veca vector
Description vector->list returns a newly allocated list of the elements of the vector vec.
R4RS Compliance Full
Examples
(vector->list #(foo bar)) => (foo bar)
(vector->list (make-vector 10 42)) => (42 42 42 42 42 42 42 42 42 42)

vector-length

vector-length counts the elements in a vector.

Category Primitive procedure
Format (vector-length vec)
Parameters
veca vector
Description vector-length returns the number of elements in vec.
R4RS Compliance Full
Examples
(vector-length #(foo bar)) => 2
(vector-length (make-vector 97 #n)) => 97
(vector-length (vector)) => 0

vector-ref

vector-ref returns an element of a vector by index.

Category Primitive procedure
Format (vector-ref vec index)
Parameters
veca vector
indexan integer
Description vector-ref returns the indexth element of vec. The index of the first element is 0, and the index of the last element is the length of vec minus one.
R4RS Compliance Full
Examples
(vector-ref #(foo bar) 1) => bar
(vector-ref #(0 1 2 3) 5) => error

vector-set!

vector-set! modifies an element in a vector.

Category Primitive procedure
Format (vector-set! vec index obj)
Parameters
veca vector
indexan integer
objany object
Description vector-set! replaces the indexth element of vec by obj. The modified vector is returned. The index of the first element is 0, and the index of the last element is the length of vec minus one. It's no error to modify a constant vector in LispMe, as all values are heap-allocated and constant vectors are never shared, so the examples are valid.
R4RS Compliance Full
Examples
(vector-set! #(1 2 3) 2 #\r) => #(1 2 #\r)
(vector-set! (make-vector 10 'jamaica) -4 'rum) => error

vector?

vector? recognizes vectors.

Category Primitive procedure
Format (vector? obj)
Parameters
objany object
Description vector? returns #t for a vector and #f for any other object.
R4RS Compliance Full
Examples
(vector? '(1 2 3)) => #f
(vector? '#(1 2 3)) => #t
(vector? 'x) => #f

Back to index A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Other