Procedure must be a procedure taking as many arguments as there are lists. If more than one list is given, then they must all be the same length.
mapapplies procedure element-wise to the elements of the lists and returns a list of the results, in order from left to right. The dynamic order in which procedure is applied to the elements of the lists is unspecified; usefor-eachto sequence side effects.(map cadr '((a b) (d e) (g h))) => (b e h) (map (lambda (n) (expt n n)) '(1 2 3 4)) => (1 4 27 256) (map + '(1 2 3) '(4 5 6)) => (5 7 9) (let ((count 0)) (map (lambda (ignored) (set! count (+ count 1)) count) '(a b c))) => unspecified
Similar to
map, except that the resulting list is terminated by initial-value rather than the empty list. The following are equivalent:(map procedure list list ...) (map* '() procedure list list ...)
Similar to
mapandmap*, respectively, except that the results of applying procedure to the elements of lists are concatenated together byappendrather than bycons. The following are equivalent, except that the former is more efficient:(append-map procedure list list ...) (apply append (map procedure list list ...))
Similar to
mapandmap*, respectively, except that the results of applying procedure to the elements of lists are concatenated together byappend!rather than bycons. The following are equivalent, except that the former is more efficient:(append-map! procedure list list ...) (apply append! (map procedure list list ...))
The arguments to
for-eachare like the arguments tomap, butfor-eachcalls procedure for its side effects rather than for its values. Unlikemap,for-eachis guaranteed to call procedure on the elements of the lists in order from the first element to the last, and the value returned byfor-eachis unspecified.(let ((v (make-vector 5))) (for-each (lambda (i) (vector-set! v i (* i i))) '(0 1 2 3 4)) v) => #(0 1 4 9 16)