How do you wright a Letrec interperter in Scheme can you giv

How do you wright a Letrec interperter in Scheme, can you give an example or find one?

Solution

Syntactically letrec looks like let
Like let,including left-right evaluation of val-expressions,but the locations for all ids are created first.
All ids are bound in all val-exprs as well as bodys,The ids must be distinct according to bound-identifier=?.
Referencing or assigning to an id before its initialization raises exn:fail:contract:variable.
If an id(i.e., the binding instance or id) has an \'undefined-error-name syntax property whose value is a symbol,
The symbol is used as the name of the variable for error reporting,instead of symbolic form of id.
Example:

>(letrec (is-even? (lambda (n)
   (or (Zero? n)
   (is odd? (sub1 n))))]
[is-odd? (lambda (n)
   (and (not (Zero? n))
(is-even? (sub1 n))))])
   (is-odd? 11))

How do you wright a Letrec interperter in Scheme, can you give an example or find one?SolutionSyntactically letrec looks like let Like let,including left-right

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site