Skip to content

Instantly share code, notes, and snippets.

@drewlesueur
Created June 26, 2012 20:34
Show Gist options
  • Save drewlesueur/2998748 to your computer and use it in GitHub Desktop.
Save drewlesueur/2998748 to your computer and use it in GitHub Desktop.
need_y_combinator.coffee
# normal factorial
factorial = (x) ->
if x == 1 then return 1
return x * factorial(x - 1)
console.log factorial(6) #720
# new factorial that doesn't reference itself
factorialGenerator = (fac) ->
(x) ->
if x == 1 then return 1
return x * fac(x - 1)
# imagine the function Y exists
# what function Y would make this work equal 720?
console.log Y(factorialGenerator)(7) #720
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment