3 ms·
Here's a CoffeeScript fixed-point combinator I wrote some time ago: y = ((y)->y y) (y) -> (f) -> (n) -> (f (y y) f) n Its a little different than the common
by nadaviv 13y ago
Here's a CoffeeScript fixed-point combinator I wrote some time ago:
y = ((y)->y y) (y) -> (f) -> (n) -> (f (y y) f) n
Its a little different than the common implementation of y combinator, but looks cooler imo :)
edit: also, a question - a comment on stackoverflow says that fixed-point combinators are used to prove the turing-completeness of lambda calculus. Can't it be proved with something simpler, such as that?
y = (f) -> (n) -> (f f) n
fact = y (f) -> (n) -> if n is 0 then 1 else n * (f f) n-1
- reycharles 13y agoYou don't need turing completeness to implement the factorial function, hence it is not a proof of turing completeness.