Previous: , Up: vectors fold   [Index]


24.7.4 Mapping functions

All the functions described here map their proc function argument over all the elements of the vector arguments, or the subvector argument, from zero to the end in increasing order. In all the following descriptions:

Function: vector-map* proc vec0 vec ...
Function: vector-map/with-index proc vec0 vec ...
Function: vector-map*/with-index proc vec0 vec ...

Build and return a new vector holding the return values of mapping proc over all the elements of the vector arguments.

Function: vector-map! proc vec0 vec ...
Function: vector-map*! proc vec0 vec ...
Function: vector-map!/with-index proc vec0 vec ...
Function: vector-map*!/with-index proc vec0 vec ...

Mutate vec0 setting its elements to the return values of mapping proc over all the elements of the vector arguments.

Function: vector-for-each* proc vec0 vec ...
Function: vector-for-each*/with-index proc vec0 vec ...

Apply proc over all the elements of the vector arguments.

Mapping over subvectors

Function: %subvector-map proc vec start past
Function: %subvector-map/with-index proc vec start past
Macro: subvector-map proc S
Macro: subvector-map/with-index proc S

Build and return a new vector mapping proc over the items in the selected subvector of vec, from index start to index past in increasing order.

Function: %subvector-map! proc vec start past
Function: %subvector-map!/with-index proc vec start past
Macro: subvector-map! proc S
Macro: subvector-map!/with-index proc S

Mutate the selected subvector of vec, mapping proc over its items from index start to index past in increasing order.

Function: %subvector-for-each proc vec start past
Function: %subvector-for-each/with-index proc vec start past
Macro: subvector-for-each proc V
Macro: subvector-for-each/with-index proc V

Apply proc to each item in the selected subvector of vec, from index start to index past in increasing order.

Function: %subvector-for-each-index proc vec start past
Macro: subvector-for-each-index proc V

Apply proc to each index in the selected subvector of vec, from index start to index past in increasing order. This is simply a method of looping over a vector that is guaranteed to be safe and correct.

Syntax variants

The following syntaxes are like the corresponding functions. They can be a little faster when multiple vector arguments are present.

Syntax: vector-map/stx proc vec0 vec ...
Syntax: vector-map*/stx proc vec0 vec ...

Like vector-map and vector-map*, but implemented as a syntax.

Syntax: vector-map!/stx proc vec0 vec ...
Syntax: vector-map*!/stx proc vec0 vec ...

Like vector-map! and vector-map*!, but implemented as a syntax.

Syntax: vector-for-each/stx proc vec0 vec ...
Syntax: vector-for-each*/stx proc vec0 vec ...

Like vector-for-each and vector-for-each*, but implemented as a syntax.


Previous: , Up: vectors fold   [Index]