This function is an exception to the aforementioned functional programming style, having as its objective to cause side-effects and not to return evaluated expressions.
Such side-effects may be to display data on the screen or to send them to printer. It is obvious that procedures like this, applying the imperative programming style are sometimes needed and important as well.
(define for-each (lambda(procedure lis) (if (nullp lis) true ((lambda() (procedure (car lis)) (for-each procedure (cdr lis) )))))) |
(define l1 (cons seven (cons eight (cons nine (cons ten nil))))) ; (for-each ndisp! l1) --> 7 8 9 10 |
Georg P. Loczewski 2004-03-05