To remove all shortcuts in an expression, you can do this:
- Replace the procedure definition from this form:
(define f (lambda (x) x))
with this equivalent form: (define (fx) x)
- Replace
letrec
expression with internal definition - Replace
lambda
in the last line with another internal definition, name it and name it at the end - Even simpler: note that you really don't need the latest
lambda
, as this is equivalent to a direct call (hxx)
After successive application of each of the above substitutions, the procedure ends as follows:
(define (foo x) (define (hyz) (cond ((null? y) 'undefined) ((null? (cdr y)) (car z)) (else (h (cddr y) (cdr z))))) (hxx))
Please note that lambda
not actually eliminated, they are still under the hood - hidden behind syntactic sugar.
source share