This provides an implementation of persistent, immutable vectors. They are implemented as 32-way bitmapped tries with a tail to provide truly constant time appends to the end of the vector. Data is shared between a vector and its subsequent functional modifications.
The persistent vectors provided by this module implement the gen:equal+hash generic interface, so they may be used as keys, and equal? will perform deep comparisons. Additionally, they implement three interfaces from data/collection, gen:countable , gen:collection , and gen:sequence , which contain the interface for interacting with them.
Persistent vectors may be created using the pvector constructor.
#pv[1 2 3 4]
Afterwards, they can be interacted with via the functions from data/collection.
#pv[1 2 3 4 5]
It is often useful to create an empty vector using (pvector ), then extending it with some other sequence.
#pv[0 1 2 3 4 5 6 7 8 9]
The interface provided by data/pvector is small. Most of the functions for manipulating persistent vectors reside in data/collection. However, some functions are specific to persistent vectors.
procedure
( build-pvector nproc)→pvector?
procedure
( make-pvector nv)→pvector?
v:any/c
syntax
( for/pvector (for-clause...)body-or-break...body)
syntax
( for*/pvector (for-clause...)body-or-break...body)