next up previous
Contents Next: Backquote and Commas Up: FunctionsLambda Expressions, Previous: Apply

Mapcar

[We are grateful to John H. Remmers for allowing material from his programming languages course to be incorporated into this section.]

The MAPCAR form is an "iterator" that applies a function repeatedly, to each element of a list and returns a list of the results. For example:

> (mapcar 'atom '(dog (cat horse) fish))
(t nil t)
> (mapcar (lambda (x) (* x x)) '(4 7 2 9))
(16 49 4 81)


© Colin Allen, John H. Remmers, & Maneesh Dhagat
March 2007