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

Lambda |

**Lambda - Y Combinator**

(define F (lambda (n) (if (zero? n) 1 (* n ((lambda (arg) ((procedure procedure) arg)) (- n 1)))))) |
- |
In general, isn't
(f arg)identical to ((lambda (x) (f x)) arg) ?The second statement is a little strange, though, because it makes you pass "arg" into a procedure so that the procedure which would be applied to it anyway is applied. Why do we want to do such a thing? Watch! This means that ((procedure procedure) (- n 1))is the same as ((lambda (arg) ((procedure procedure) arg)) (- n 1))and we substitute this into our current version of F to get the code to the left. |
||