Skip to content
Matthias Görges edited this page Jul 19, 2014 · 1 revision

vector-map is the vector-equivalent function of map for lists

Parameter Description
fcn Function applied to vector(s)
vec Vector operated on
vectors Optional: Additional vectors operated on

Example

Example 1: Show comparison of map and vector-map for lists and vectors respectively.

> (map sqrt (list 1 4 16)) 
(1 2 4)
> (vector-map sqrt (vector 1 4 16))
#(1 2 4)
> (map + (list 1 2 3 4 5) (list 9 8 7 6 5))
(10 10 10 10 10)
> (vector-map / (vector 2 3 4) (vector 1 2 3)) 
#(2 3/2 4/3)
> (vector-map (lambda (l) (+ l 2)) (vector 0 1 2 3 4))
#(2 3 4 5 6)
Clone this wiki locally