REDUCE

21.4 Lambda Expressions

lambdaexpressions provide the means for constructing Lisp lambdaexpressions in symbolic mode. They may not be used in algebraic mode.

Syntax:

\(\langle \)lambda expression\(\rangle \) \(\longrightarrow \) lambda \(\langle \)varlist\(\rangle \)\(\langle \)terminator\(\rangle \) \(\langle \)statement\(\rangle \)

where

\(\langle \)varlist\(\rangle \) \(\longrightarrow \) (\(\langle \)variable\(\rangle \),,\(\langle \)variable\(\rangle \))

e.g.,

        lambda (x,y); car x . cdr y;

is equivalent to the Lisp lambdaexpression

        (lambda (x y) (cons (car x) (cdr y)))

The parentheses may be omitted in specifying the variable list if desired.

lambdaexpressions may be used in symbolic mode in place of prefix operators, or as an argument of the reserved word function.

In those cases where a lambdaexpression is used to introduce local variables to avoid recomputation, a wherestatement can also be used. For example, the expression

    (lambda (x,y); list(car x,cdr x,car y,cdr y))
        (reverse u,reverse v)

can also be written

    {car x,cdr x,car y,cdr y}
        where x=reverse u,y=reverse v

Where possible, wheresyntax is preferred to lambdasyntax, since it is more natural.


Hosted by Download REDUCE Powered by MathJax