Hacker News new | ask | show | jobs
by i2 5297 days ago
The same can be done with Python lambdas:

  >>> ZERO = lambda f: lambda x: x
  >>> FIVE = lambda f: lambda x: f(f(f(f(f(x)))))
  >>> to_int = lambda f: f(lambda x: x+1)(0)
  ... etc.
2 comments

Mark-Jason Dominus did this for Perl, more than a decade ago.

http://perl.plover.com/lambda/ aka "How to write a 163 line program to compute 1+1"

Although I really like the OP's approach since he slowly morphs a program his readers can understand, rather than constructing a programming system from scratch.

Yeah you can do the full lambda calculus in Python:

https://raw.github.com/sdiehl/church-numbers/master/church.p...