The `map' functionexpects a modifier and a list as arguments. The modifier is applied to all elements of the list. If for a certain application the modifier remains constant but the list varies from case to case, it seems to be useful to have a function that expects only the list as argument. Such a function is built by `mapc'.
(define mapc (curry map)) ; ;;; Example 1: ;;; ; (define l1 (cons one (cons two (cons three (cons four nil))))) ; (define malzwei (mapc (lambda(x) (mult two x)))) (ldisp! (malzwei l1)) --> 2 4 6 8 ; ;;; Example 2: ;;; ; (define succ* (mapc succ)) ; (define l1 (cons one (cons two (cons three (cons four nil))))) (ldisp! (succ* l1)) --> 2 3 4 5 |
Georg P. Loczewski 2004-03-05