srfi-43- Vector library (legacy)
This module is effectively superseded by R7RS and
There are a few procedures that are not compatible with R7RS and
srfi-133, and this module remains to support
legacy code that depends on them.
See Vectors, and see Vector library, for the “modern” versions of vector library. New code should use them.
The following procedures in srfi-43 are built-in. See Vectors, for the description.
make-vector vector vector? vector-ref vector-set! vector-length vector-fill! vector-copy vector-copy! vector-append vector->list list->vector reverse-list->vector
The following procedures in srfi-43 are supported by srfi-133. See Vector library, for the description.
vector-unfold vector-unfold-right vector-reverse-copy vector-reverse-copy! vector-concatenate vector-empty? vector= vector-index vector-index-right vector-skip vector-skip-right vector-binary-search vector-any vector-every vector-swap! reverse-vector->list
We explain the procedures that are not listed above.
srfi-133, but kons
takes an extra argument, the current index, as its first argument.
So kons must accept n+2 arguments, where
n is the number of given vectors.
It is called as
(kons <index> <cumulated-value> <elt1> <elt2> ...).
fold-with-index (see Mapping over sequences)
that can be used to fold vectors with index, but the argument order
of kons is slightly different: It passes the index, each
element from argument vectors, then cumulated values.
(use srfi-43) (vector-fold list '() '#(a b c) '#(d e f)) ⇒ (2 (1 (0 () a d) b e) c f) (use gauche.sequence) (fold-with-index list '() '#(a b c) '#(d e f)) ⇒ (2 c f (1 b e (0 a d ())))
vector-for-each of R7RS,
except f takes
an extra argument, the current index, as its first argument.
which are the same as
vector-for-each, respectively. See Vectors.
(vector-map list '#(a b c)) ⇒ #((0 a) (1 b) (2 c)) (vector-map list '#(a b c) '#(d e f g)) ⇒ #((0 a d) (1 b e) (2 c f)) (vector-count = '#(0 2 2 4 4)) ⇒ 3
vector-count example calls
two arguments, the current index and the element, for each element
of the input vector. So it counts the number of
occasions when the element is equal to the index.)
gauche.collection can be used
on vectors, but the mapped procedure is called without index, and the result
is returned as a list.
(vector-map f vec1 vec2 …) is operationally equivalent to
(map-to-with-index <vector> f vec1 vec2 …).
See Collection framework and Sequence framework.