3 ms·
Curiously, in the pure lambda calculus with Church numerals, the factorial function doesn't need recursion, since Church numerals already act like iterators: fa
by tromp 2y ago
Curiously, in the pure lambda calculus with Church numerals, the factorial function doesn't need recursion, since Church numerals already act like iterators: fac = λn.λf.n(λf.λn.n(f(λf.λx.n f(f x))))(λx.f)(λx.x) or as a lambda diagram:
┬────────────────
┼─────────────┬──
│ ──┬──────── ┼ ┬
│ ┬─┼─┬────── │ │
│ │ │ ┼─┬─┬── │ │
│ │ │ ┼─┼─┼─┬ │ │
│ │ │ └─┤ ├─┘ │ │
│ │ │ ├─┘ │ │
│ │ ├───┘ │ │
│ ├─┘ │ │
└─┤ │ │
└───────────┤ │
└─┘