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

Lambda calculus, Type theory, Formal semantics, Program analysis

    Prev     Next     All lectures           Code

Lambda - Y Combinator

(define fact
  (lambda (n)
    (if (zero? n)
        (* n (fact (- n 1))))))
 -  The procedure to the left computes n! recursively, and the name given to the procedure is in its body. It seems to need the name "fact" in the last line so that it can recurse on itself. But, we will see this is not necessary and, in the process, will develop a lot of intuition about using Scheme. We proceed step by step, changing "fact" slightly on each step.