chickadee » scheme » map

(map proc list[1] list[2] ...)procedure

The lists must be lists, and proc must be a procedure taking as many arguments as there are lists and returning a single value. If more than one list is given, then they must all be the same length. Map applies proc element-wise to the elements of the lists and returns a list of the results, in order. The dynamic order in which proc is applied to the elements of the lists is unspecified.

(map cadr '((a b) (d e) (g h)))   
                ===>  (b e h)

(map (lambda (n) (expt n n))
     '(1 2 3 4 5))                
                ===>  (1 4 27 256 3125)

(map + '(1 2 3) '(4 5 6))                 ===>  (5 7 9)

(let ((count 0))
  (map (lambda (ignored)
         (set! count (+ count 1))
         count)
       '(a b)))                         ===>  (1 2) or (2 1)