I need to eliminate this Scheme lambda construction for my school assignment.
Any ideas how to accomplish this?
(define (foo x)
(letrec
((h
(lambda (y z)
(cond
((null? y) 'undefined)
((null? (cdr y)) (car z))
(else (h (cddr y) (cdr z)))
))))
(h x x))
)
Well, you could replace the
lambdaexpression in theletrecwith an internal definition:… Or you could extract the
hprocedure outside offoo, as a helper procedure. Either way the result would be the same.