racket Higher Order Functions Map


Example

Map applies a function to every element of a list:

map: (a -> b) (listof a) -> (listof b)

> (map (lambda (x) (* x 2)) (list 1 2 3 4 5)
(list 2 4 6 8 10)

> (map sqrt (list 1 4 9))
(list 1 2 3)

> (map (lambda (x) (if (even? x) "even" "odd")) (list 1 2 3))
(list "odd" "even" "odd")