I am currently, going through this great article on Y-combinator by Mike Vanier. Along the explanation the following line is dropped:
It turns out that any let expression can be converted into an equivalent lambda expression using this equation:
(let ((x <expr1>)) <expr2>) ==> ((lambda (x) <expr2>) <expr1>)
The article illustrates this statement by converting:
(define (part-factorial self)
(let ((f (self self)))
(lambda (n)
(if (= n 0)
1
(* n (f (- n 1)))))))
to:
(define (part-factorial self)
((lambda (f)
(lambda (n)
(if (= n 0)
1
(* n (f (- n 1))))))
(self self)))
Now, I understand how and why two code snippets above are identical, though I can't get my head around the fact that general equation for converting let
to lambda
is:
(let ((x <expr1>)) <expr2>)
==> ((lambda (x) <expr2>) <expr1>)
I'd appreciate the elaborate explanation.