4.7 Lambda Expressions and Local Assignments
TBoS p.70-71, p.85-87
(λ x (* x x)) is written as '(/. X (* X X))' in Shen. It is customary to use capital letters for
variables. '(/. X Y Z (+ X Y Z))' is an acceptable abbreviation for '(/. X (/. Y (/. Z (+ X Y Z))'. You can also
write '(lambda X (+ X X))' though this form does not sustain abbreviations, '(lambda X Y (+ X Y))' is not legal
(it should be '(lambda X (lambda Y (+ X Y)))').
Local assignments are made using 'let'. 'let' takes a variable v, an expression e11 and
an expression e2 and binds v to the normal form of e1 in the evaluation of e2.
'let' is polyadic;
(let X1 a1 ... Xn an Y)
is short for
(let X1 a1 ...
(let Xn an) Y). |