Lambda Calculus in Clojure (Part 2)
In Part 1, we built a boolean algebra using Church Encoding. In this post, we are going to reuse some of the previous work to build a similar algebra, this time for numerals. Church numerals In the algebra we built in the previous post, Church booleans were encoded using higher-order functions. The way Church numerals are represented is similar: given a number n and a function f, the Church numeral of n is the number of times f encapsulates n. For example, for n = 3, the function f encapsulates n three times: ...