Next: vectors convention, Up: vectors [Index]
The functions are split in a high level library, (vicare
containers vectors)
, and a low level one, (vicare containers
vectors low)
. The main difference between the two layers is that the
high level library makes heavy usage of macros to implement the
vector views, which allow accessing subvectors using a friendly
syntax.
All the functions in the low level library are bound to identifiers
starting with %
; for example: vector-prefix?
is a high
level macro, %vector-prefix?
is its low level function
homologous.
The library accesses the values of a vector in left–to–right or right–to–left order depending on the convenience of the algorithm.
Care must be taken when using functions with side effects. One reason for this is that some of the supported Scheme implementations will treat a literal vector as a constant, so the following raises an error:
(import (rnrs)) (define vec '#(0 1 2 3 4)) (vector-set! vec 2 #\9)
To avoid this problem completely, we can change the program in this way:
(import (rnrs)) (define vec (vector-copy '#(0 1 2 3 4))) (vector-set! vec 2 #\9)
of course we may want to wrap into vector-copy
only the vectors
that are meant to be mutated.