3 ms·
What's really interesting beyond just type coercion and "increment," is the way addition, multiplication, and exponentiation were implemented by Church and Ross
by brianmwaters_hn 12y ago
What's really interesting beyond just type coercion and "increment," is the way addition, multiplication, and exponentiation were implemented by Church and Rosser back in the 30's (see https://en.wikipedia.org/wiki/Lambda_calculus https://en.wikipedia.org/wiki/Lambda_calculus). Rather than using SICP-style recursion to count down to zero and repeatedly apply inc/add/mul, they took advantage of some of the special properties of Church numerals. A year later, and I still have not really wrapped my head around their solutions. Maybe you will fare better.
For a real challenge, try to implement the decrement function. Legend has it, Rosser thought of the solution while on the dentist's chair. (It is a bit heavier on code than the other Church numeral functions, but conceptually simple - and was a creative idea at the time, before functional programming had really come into being.)
- tromp 12y agoThe graphical notation for the decrement function ┬────────── ┼─────┬──── ┼─────┼─┬── │ ──┬─┼ ┼ ┬ │ ┬─┼─┼ │ │ │ │ ├─┘ │ │ │ ├─┘ │ │ └─┤ │ │ └─────┤ │ └─┘ makes for an artistic picture...