Previous: lists fold map, Up: lists fold [Index]
This procedure extends the R6RS specification for for-each to
allow the arguments to be of unequal length; it terminates when the
shortest list runs out of elements.
The arguments to for-each* are like the arguments to map*,
but for-each* calls proc for its side effects rather than
for its values. Unlike map*, for-each* is guaranteed to
call proc on the elements of the lists in order from the first
element(s) to the last, and the value returned by for-each* is
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)
At least one of the list arguments must be a finite list.
Like for-each, but f is applied to successive sublists of
the argument lists. That is, f is applied to the cons cells of
the lists, rather than the lists’ elements. These applications occur in
left–to–right order.
The f procedure may reliably apply set-cdr! to the pairs it
is given without altering the sequence of execution.
(pair-for-each
(lambda (pair)
(display pair)
(newline))
'(a b c))
-| (a b c)
-| (b c)
-| (c)
The list arguments must have equal length.
Like for-each*, but f is applied to successive sublists of
the argument lists. That is, f is applied to the cons cells of
the lists, rather than the lists’ elements. These applications occur in
left–to–right order.
The f procedure may reliably apply set-cdr! to the pairs it
is given without altering the sequence of execution.
(pair-for-each*
(lambda (pair)
(display pair)
(newline))
'(a b c))
-| (a b c)
-| (b c)
-| (c)
At least one of the list arguments must be a finite list.
Previous: lists fold map, Up: lists fold [Index]