The notation for an anonymous function uses the special operator called
lambda and looks like this:
(lambda ( arg-1 ...
) exp-1 ...
(lambda ( arg-1 ... arg-m
exp-1 ... exp-n
(Note: in Common Lisp, this form is prefixed by #'.) It can be used in the function position in a function application:
(lambda (x) ...)is applied to the argument
3. In the second the function
(lambda (x . y) ...)is applied to the arguments
3, the second and third of which become the elements of a list bound to
y, which gives the result.
foo, which takes an argument
fand an argument
xand calls the function which is the value of
fwith the arguments
(+ x 1). Hence, if we call
3we obtain the result of
(+ 3 (+ 1 3)). In the second case,
fis a function of two arguments which computes the product of the two arguments and
add-nis a function of one argument, in which the value of
3, by virtue of the anonymous functional result being defined in the environment where
nis associated with
3. We can visualize this using the same technique as before: