lambdaExpression: Useful Anonymity
lambda is the symbol for an anonymous function, a function
without a name. Every time you use an anonymous function, you need to
include its whole body.
(lambda (arg) (/ arg 50))
is a function definition that says `return the value resulting from
dividing whatever is passed to me as
arg by 50'.
Earlier, for example, we had a function
multiplied its argument by 7. This function is similar, except it
divides its argument by 50; and, it has no name. The anonymous
(lambda (number) (* 7 number))
defun Special Form.)
If we want to multiply 3 by 7, we can write:
(multiply-by-seven 3) \_______________/ ^ | | function argument
This expression returns 21.
Similarly, we can write:
((lambda (number) (* 7 number)) 3) \____________________________/ ^ | | anonymous function argument
If we want to divide 100 by 50, we can write:
((lambda (arg) (/ arg 50)) 100) \______________________/ \_/ | | anonymous function argument
This expression returns 2. The 100 is passed to the function, which divides that number by 50.
See Lambda Expressions, for more about
lambda. Lisp and lambda
expressions derive from the Lambda Calculus.