Lambda

Lambda

Robbert Haarman

2010-12-11

The lambda operator has the following syntax:

(lambda (arguments) body)

It defines a function which takes the specified arguments and evaluates the expressions in body, returning the value of the last expression evaluated. Lambda expressions are very useful in combination with constructs that apply them to every element of a lists. For example:

(map (lambda (x) (+ x 2)) '(1 2 3)) ; => (3 4 5)

In principle, almost any construct in Scheme can be modeled by lambda. However, many common constructs have been defined, and it's easier and clearer to use those.

Valid XHTML 1.1! Valid CSS! Viewable with Any Browser