Next: lists fold foreach, Previous: lists fold unfold, Up: lists fold [Index]
This procedure extends the R6RS specification of map to allow
the arguments to be of unequal length; it terminates when the shortest
list runs out of elements.
proc is a procedure taking as many arguments as there are list
arguments and returning a single value. 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)
At least one of the list arguments must be a finite list:
(map* +
'(3 1 4 1)
(circular-list 1 0))
⇒ (4 1 5 1)
A variant of the map procedure that guarantees to apply f
across the elements of the circ arguments in a left–to–right
order. This is useful for mapping procedures that both have side
effects and return useful values.
At least one of the list arguments must be finite.
Equivalent to:
(apply append (map f clist1 clist2 ...))
and:
(apply append! (map f clist1 clist2 ...))
so it makes sense to use these functions only when the list returned by the map process is a list of lists.
Map f over the elements of the lists, just as in the map
function. However, the results of the applications are appended
together to make the final result. append-map uses append
to append the results together; append-map! uses append!.
The dynamic order in which the various applications of f are made is not specified.
Example:
(append-map!
(lambda (x)
(list x (- x)))
'(1 3 8))
⇒ (1 -1 3 -3 8 -8)
(append-map! list
'(1 2 3)
'(10 20 30))
⇒ (1 10 2 20 3 30)
At least one of the list arguments must be a finite list.
Like map and map/stx, but they are allowed to alter the
cons cells of ell0 to construct the result list.
The dynamic order in which the various applications of f are made is not specified. In the n–ary case, all the list arguments must have the same number of elements.
Like map* and map*!/stx, but they are allowed to alter the
cons cells of ell to construct the result list.
The dynamic order in which the various applications of f are made is not specified. In the n–ary case, circ ... must have at least as many elements as ell.
Like map, but only true values are mapped:
(filter-map
(lambda (x)
(and (number? x)
(* x x)))
'(a 1 b 3 c 7))
⇒ (1 9 49)
The dynamic order in which the various applications of f are made is not specified. At least one of the list arguments must be finite.
Like filter-map and filter-map/stx, but accept list
arguments of different length.
Next: lists fold foreach, Previous: lists fold unfold, Up: lists fold [Index]