## LIBRARY

```(import (rnrs))                     ;R6RS
(import (rnrs base))                ;R6RS
(import (scheme base))              ;R7RS
```

## SYNOPSIS

```(vector-map proc vector1 vector2 ...)
```

## DESCRIPTION

The vector-map procedure applies proc element-wise 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 vector-map itself.

The order in which proc is applied to the elements of the vectors is unspecified.

If multiple returns occur from vector-map, 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, vector-map terminates when the shortest vector runs out.

## RETURN VALUES

Returns a single value which is a vector object.

## EXAMPLES

```(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))
(vector-map
(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.

map(3scm), string-map(3scm), vector-for-each(3scm)

## STANDARDS

R6RS, R7RS, SRFI-43

## HISTORY

The first RnRS report to carry this procedure was R6RS. R7RS also included it, basing it on the semantics from SRFI-43.

## AUTHORS

This page is part of the scheme-manpages 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.