This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home. For a version of this page that may be more recent, see VectorsCowan in WG2's repo for R7RS-large.

Vectors­Cowan

cowan
2014-11-05 05:24:59
14history
source

This is a preliminary list of procedures for the R7RS vector library. It is an upward compatible extension of the vector libraries of R5RS, R7RS-small, and SRFI 43, with additional procedures that are analogous to procedures in the SRFI 1 list library. As a single exception, the vector-copy procedure in R7RS-small does not provide the fill argument present in SRFI 43.

The procedures that are already in R7RS-small will not be overridden by this library, and are listed only for completeness.

Notation

Constructors

make-vector (R5RS), vector (R5RS), vector-iota (SRFI 1) \\ vector-unfold (SRFI 43), vector-unfold-right (SRFI 43) \\ vector-copy (R7RS), vector-copy! (R7RS) \\ vector-reverse-copy (SRFI 43+), vector-reverse-copy! (SRFI 43+) \\ vector-append (R7RS), vector-append! (SRFI 1) \\ vector-append-subvectors (see below) \\ vector-concatenate (SRFI 43), vector-concatenate! (SRFI 1) \\ vector-tabulate (SRFI 1), vector-tabulate! (SRFI 1)

Predicates

vector? (R5RS), vector-empty? (SRFI 43), vector= (SRFI 43+)

Selectors

vector-ref (R5RS), vector-length (R5RS) \\ vector-take (SRFI 1), vector-take-right (SRFI 1) \\ vector-drop (SRFI 1), vector-drop-right (SRFI 1) \\ vector-split-at (SRFI 1)

Iteration

vector-fold (SRFI 43+), vector-fold-right (SRFI 43+) \\ vector-reduce (SRFI 43+), vector-reduce-right (SRFI 43+) \\ vector-map (SRFI 43+), vector-map! (SRFI 43+) \\ vector-for-each (R7RS)

The above procedures do not pass the index value to the mapping function, for compatibility with R7RS vector-map and vector-fold. The following versions, which are compatible with SRFI 43, pass the index value as the first argument.

vector-fold-index (SRFI 43+), vector-fold-right-index (SRFI 43+) \\ vector-reduce-index (SRFI 43+), vector-reduce-right-index (SRFI 43+) \\ vector-map-index (SRFI 43+), vector-map-index! (SRFI 43+) \\ vector-for-each-index (R7RS)

Filtering and partitioning

vector-count (SRFI 43+) \\ vector-filter (SRFI 1), vector-remove (SRFI 1), vector-partition (SRFI 1) \\ vector-filter! (SRFI 1), vector-remove! (SRFI 1), vector-partition! (SRFI 1)

Deleting

vector-delete (SRFI 1), vector-delete-duplicates (SRFI 1) \\ vector-delete! (SRFI 1), vector-delete-duplicates! (SRFI 1)

Searching

vector-find (SRFI 1) \\ vector-index (SRFI 43+), vector-index-right (SRFI 43+) \\ vector-skip (SRFI 43+), vector-skip-right (SRFI 43+) \\ vector-any (SRFI 43+), vector-every (SRFI 43+) \\ vector-take-while (SRFI 1+), vector-drop-while (SRFI 1+) \\ vector-binary-search (SRFI 43+) \\ vector-span (SRFI 1), vector-span! (SRFI 1) \\ vector-break (SRFI 1), vector-break! (SRFI 1)

Mutators

vector-set! (R5RS), vector-swap! (SRFI 43) \\ vector-fill! (R5RS+), vector-reverse! (SRFI 43+) \\ vector-copy! (R7RS), vector-reverse-copy! (SRFI 43+)

Conversion

vector->list (R5RS+), reverse-vector->list (SRFI 43+) \\ list->vector (R5RS), reverse-list->vector (SRFI 43) \\ vector->string (R7RS), string->vector (R7RS)

Additional procedures

(vector-append-subvectors k fill ( at vector start end stride ) ...)

Returns a newly allocated vector of length k after copying every stride-th element of each vector from start to end into the new vector starting at at. Any additional locations in the new vector are initialized with fill. This procedure is a generalization of vector-copy and vector-copy!. Implementations may optimize this procedure using an unsafe primitive that creates an uninitialized vector, in order to avoid touching each element of the result twice.

(vector-cumulate proc seed vector)

Returns a newly allocated vector of the same length as vector. Each element is constructed by reducing (as if by vector-reduce) successive prefixes of the elements of vector. (APL scan.)