vectormap  map a procedure over the elements of vectors
LIBRARY
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
(import (scheme base)) ;R7RS
SYNOPSIS
(vectormap proc vector1 vector2 ...)
DESCRIPTION
The vectormap procedure applies
proc
elementwise to
the elements of the
vectors
and returns a vector of the results, in order.
Proc
is always called in the same dynamic
environment as
vectormap
itself.
The order in which
proc
is applied to the elements of the vectors is unspecified.
If multiple returns occur from
vectormap,
the return values returned by earlier returns are not mutated.
 R6RS

The vectors must all have the same length.
 R7RS

If more than one vector is given and not all vectors have the same
length,
vectormap
terminates when the shortest vector runs out.
RETURN VALUES
Returns a single value which is a vector object.
EXAMPLES
(vectormap cadr '#((a b) (d e) (g h)))
=> #(b e h)
(vectormap (lambda (n) (expt n n))
'#(1 2 3 4 5))
=> #(1 4 27 256 3125)
(vectormap + '#(1 2 3) '#(4 5 6 7))
=> #(5 7 9) ; R7RS
raises &assertion ; R6RS
(let ((count 0))
(vectormap
(lambda (ignored)
(set! count (+ count 1))
count)
'#(a b)))
=> #(1 2) or #(2 1)
APPLICATION USAGE
This procedure is used in place of
map(3scm)
when vectors are used instead of lists.
COMPATIBILITY
The R6RS version is consistent with the R6RS version of
map(3scm)
in that it requires all vectors to be the same length, and R7RS is
likewise consistent with its version of
map(3scm)
in instead using the shortest vector.
ERRORS
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
proc
does not accept a single value, and may be raised if it does not return
a single value.
 R7RS

The assertions described above are errors.
Additionally it is an error if
proc
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.
SEE ALSO
map(3scm),
stringmap(3scm),
vectorforeach(3scm)
STANDARDS
R6RS,
R7RS,
SRFI43
HISTORY
The first RnRS report to carry this procedure was R6RS. R7RS also
included it, basing it on the semantics from SRFI43.
AUTHORS
This page is part of the
schememanpages
project.
It includes materials from the RnRS documents.
More information can be found at
https://github.com/schemedoc/manpages/
.
Markup created by unroff 1.0sc, March 04, 2023.