Next: Filesystem Tree Walk, Previous: Common List Operations, Up: Top
A lol is a list of lists, with all the sub-lists having the same number of elements. It is a common structure for smallish inline data sets. The expression:
makes available some convenient syntax sugaring of apply,
map and for-each. In these macros, formals
should be a list of symbols naming the variables to be bound
to each sub-list element for the forms in body.
Apply the procedure
(lambdaformals body)to the sub-lists of lol and return the results as a list.
Apply the procedure
(lambdaformals body)to the sub-lists of lol.
The following example shows two idempotent fragments
(they both display monday and wednesday),
written “manually” and with lol-for-each.
(define TABLE '((#t monday)
(#f tuesday)
(#t wednesday)))
(for-each (lambda (sub)
(apply (lambda (sleep? day)
(and sleep? (write-line day)))
sub))
TABLE)
(lol-for-each (sleep? day) TABLE
(and sleep? (write-line day)))