Slide 12.12: Reduction strategies (cont.) Slide 12.14: Recursive functions Home |
<expr> ::= <var> ; lowercase identifiers | <constant> ; predefined objects | ( <expr> <expr> ) ; combinations | ( &lambda <var> . <expr> ) ; abstractions | let <decs> in <expr> <decs> ::= <dec>, <decs> | <dec> <dec> ::= <ident> = <expr>Note that this form is not intended to allow explicitly recursive definitions. Declarations can be removed systematically, perhaps by a compiler, using the following transformation:
let x=e in f ⇒ ( λx.f ) eFor more than one declaration,
let x=e, y=f in g ⇒ (λxy.(λx.λy.g) (hd xy) (tl xy)) (e::f)
hd
: the head function such as the Lisp car
.
For example,
( hd e::f ) = e
tl
: the tail function such as the Lisp cdr
.
For example,
( tl e::f ) = f
::
”: the cons
function such as the Lisp cons
.