Application

Scheme has a special form, (map), for applying a given function to each atom in a list. For example, to get the factorials of a whole list of integers, you could use (map) at the prompt:

   > (map ! '(1 6 3 11))
   (1 720 6 39916800)
  

If the mapped function takes more than one argument, map requires a list of equal size for each argument:

   > (map + '( 17 23 42) '(57 69 666))
   (74 92 708)
  

Contents Previous Next