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

Lambda calculus, Type theory, Formal semantics, Program analysis

    Prev     Next     All lectures           Code

Lambda - Y Combinator

(((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)))))))
 5)
 -  Consider the code to the left. This produces the factorial of 5 because the procedure which is invoked (the huge mess) is exactly the definition of "fact." But, lo and behold, there is no name for this procedure anywhere!

In what follows, we try to generalize this to all procedures of one argument and wind up with the applicative-order Y-combinator.