vector-map - map a procedure over the elements of vectors
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme base)) ;R7RS
(vector-map proc vector1 vector2 ...)
The vector-map procedure applies
the elements of the
and returns a vector of the results, in order.
is always called in the same dynamic
The order in which
is applied to the elements of the vectors is unspecified.
If multiple returns occur from
the return values returned by earlier returns are not mutated.
The vectors must all have the same length.
If more than one vector is given and not all vectors have the same
terminates when the shortest vector runs out.
Returns a single value which is a vector object.
(vector-map cadr '#((a b) (d e) (g h)))
=> #(b e h)
(vector-map (lambda (n) (expt n n))
'#(1 2 3 4 5))
=> #(1 4 27 256 3125)
(vector-map + '#(1 2 3) '#(4 5 6 7))
=> #(5 7 9) ; R7RS
raises &assertion ; R6RS
(let ((count 0))
(set! count (+ count 1))
=> #(1 2) or #(2 1)
This procedure is used in place of
when vectors are used instead of lists.
The R6RS version is consistent with the R6RS version of
in that it requires all vectors to be the same length, and R7RS is
likewise consistent with its version of
in instead using the shortest vector.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
Likewise this is raised if
does not accept a single value, and may be raised if it does not return
a single value.
The assertions described above are errors.
Additionally it is an error if
does not return a single value.
Implementations may signal an error, extend the procedure's
domain of definition to include such arguments,
or fail catastrophically.
The first RnRS report to carry this procedure was R6RS. R7RS also
included it, basing it on the semantics from SRFI-43.
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
Markup created by unroff 1.0sc, March 04, 2023.