REDUCE

17.4 Lambda Expressions

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

Syntax:

LAMBDAexpression ::=
LAMBDA varlistterminatorstatement

where

varlist ::= (variable,,variable)

e.g.,

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

is equivalent to the Lisp LAMBDA expression

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

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

LAMBDA expressions 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 LAMBDA expression is used to introduce local variables to avoid recomputation, a WHERE statement 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, WHERE syntax is preferred to LAMBDA syntax, since it is more natural.