chickadee » sparse-vectors » sparse-vector?

make-sparse-vector #!optional DEFAULTprocedure
sparse-vector? xprocedure
sparse-vector-ref sparse-vector kprocedure
sparse-vector-set! sparse-vector k valueprocedure
sparse-vector->list sparse-vectorprocedure

make-sparse-vector, sparse-vector-ref and sparse-vector-set! are analogous to make-vector, vector-ref and vector-set!, except that the indices passed to sparse-vector-ref and sparse-vector-set! can be arbitrarily large.

The optional DEFAULT argument to the make-sparse-vector procedure specifies the default value for indices whose elements have not been set. If the element at index i has not been set, (sparse-vector-ref i) returns DEFAULT or #f, if DEFAULT was not specified when creating the vector.

sparse-vector->list is for debugging: It returns a list of the consecutive elements in a sparse vector from 0 to the highest element that has been set. Note that the list will also include all the #f elements for the unset elements.

(set! (sparse-vector-ref sparse-vector index) value) is supported.