
7 Dec
2008
7 Dec
'08
5:34 a.m.
On Sun, Dec 7, 2008 at 3:05 AM, Hans Aberg
One can define operators a ^ b := b(a) -- Application in inverse. (a * b)(x) := b(a(x)) -- Function composition in inverse. (a + b)(x) := a(x) * b(x) O(x) := I -- Constant function returning identity. I(x) := x -- Identity. and use them to define lambda calculus (suffices with the first four; Church reverses the order of "*").
The simple elegance of writing this encoding just increased my already infinite love of Haskell by another cardinality. a .^ b = b a (a .* b) x = b (a x) (a .+ b) x = a x .* b x o x = i i x = x toNat x = x (+1) 0 fromNat n = foldr (.) id . replicate n Luke