re: Challenge: Write your worst program VIEW POST

FULL DISCUSSION
 

One thing that comes to my mind is this factorial implementation using only lambda calculus. In JavaScript. I took the idea from this talk and implemented it in JS.

// Y Combinator
// makes the recursion
(function (improver) {
  return (function (gen) { return gen(gen) })(
    function (gen) {
      return improver(function (v) {
        return gen(gen)(v)
      })
    }
  )
})(
// this part is the condition for the factorial
function (partial) {
  return function (n) {
    return n === 0 ? 1 : n * partial(n - 1)
  }
}
// pass any number here to get its factorial
)(5)
code of conduct - report abuse