Vectors


Building Vectors

(make-vector length val)
Standard Vector Procedure. Create a new vector of length length, containing only copies of val.
(vector val_0 val_1 ... val_n)
Standard Vector Procedure. Create a new vector of size n+1 of the form #(val_0 val_1 ... val_n).

Accessing Elements by Index

(vector-ref vec n)
Standard Vector Procedure. Get the nth element of vec. Note that elements are numbered starting at 0.
(vector-set! vec k val)
Standard Vector Procedure. Set the kth element of vec to val. (Note that vectors use 0-based indexing.)

Converting Vectors

(list->vector lst)
Standard Vector Procedure. Convert lst to a vector so that the ith value in the vector is the same as the ith value in the lst.
(vector->list vec)
Standard Vector Procedure. Convert vec to a list so that the ith value in the list is the same as the ith value in the vector.

Miscellaneous

(vector? val)
Standard Vector Predicate. Determine if val is a vector.
(vector-fill! vec val)
Standard Vector Procedure. Fill vec with multiple copies of val.
(vector-length vec)
Standard Vector Procedure. Determine the size of vec.

Jerod Weinman