Skip to content

Instantly share code, notes, and snippets.

@autotelicum
Created September 18, 2011 22:12
Show Gist options
  • Save autotelicum/1225615 to your computer and use it in GitHub Desktop.
Save autotelicum/1225615 to your computer and use it in GitHub Desktop.
Y-combinator in CoffeeScript
show = console.log
Y = (f) -> ((g) -> g g) (h) -> (args...) -> f(h(h)) args...
factorial = Y (recurse) -> (x) -> if x is 0 then 1 else x * recurse x-1
show factorial 5
@autotelicum
Copy link
Author

I have lost track of the article describing this technique. The Y-combinator is not practical or useful. Posted because I was testing my gist mechanism from acme via Inferno to Mac OS X to github. Now it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment