20-CS-4003-001 |
Organization of Programming Languages |
Fall 2017 |
---|---|---|

Lambda |

**Lambda - Y Combinator**

(define fact ((lambda (procedure) (lambda (n) (if (zero? n) 1 (* n ((procedure procedure) (- n 1)))))) (lambda (procedure) (lambda (n) (if (zero? n) 1 (* n ((procedure procedure) (- n 1)))))))) |
- |
Step 2. Recall we demand that "fact" be identical to
(procedure procedure) which in turn must be identical to
(fact-maker fact-maker) (recall the example
((fact-maker fact-maker) 5) which gives the same result as
(fact 5)). Thus, we can write "fact-maker"
as shown to the left, making use of the result of Step 1.
Try this with
prompt> (fact 5) |
||