next up previous contents index
Next: Selecting elements from a Up: Higher Order Functions Previous: Converting all elements in   Contents   Index

Converting the `map' function: `mapc'

This abstraction illustrates the usefulness of the abstraction `curry'. `mapc' converts the `map' function, which takes two arguments into a function expecting only one argument.

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:
(cons four
(ldisp! (succ* l1))
--> 2

domain access counter Georg P. Loczewski 2004-03-05