Live data from Hacker News

Recursions without names: Introduction to the Y combinator in JavaScript

blog.klipse.tech

21–30 of 33 posts

Re: Recursions without names: Introduction to the Y combinator in JavaScript

#22

To be fair, the article would be more aptly titled "Recursion without function names". In any recursion you need a way to reference the original function somehow. They're using a function parameter to accomplish that via indirection.

There are no names except function arguments.

No 'x=...'

Re: Recursions without names: Introduction to the Y combinator in JavaScript

#24
post #19

I find the Python implementation is slightly more elegant: (lambda f: f(f)) (lambda fn: lambda n: 1 if n == 0 else (n * fn(fn)(n - 1))) (5)

Yeah. But I didn't find a way to run python code in the browser. Currently in Klipse, we support javascript, ruby, clojure and php...

I did not know there was a Ruby to JS compiler. That's __really__ fascinating! Do you have plans to support Python any time soon?

Re: Recursions without names: Introduction to the Y combinator in JavaScript

#25
post #19

Earlier quoted context omitted.

Yeah. But I didn't find a way to run python code in the browser. Currently in Klipse, we support javascript, ruby, clojure and php...

I did not know there was a Ruby to JS compiler. That's __really__ fascinating! Do you have plans to support Python any time soon?

I'd love to support python.

If you find a way to evaluate python code in the browser, please let me know: viebel@gmail.com

Re: Recursions without names: Introduction to the Y combinator in JavaScript

#26
post #14

Earlier quoted context omitted.

Quoth xkcd, "Tail recusion is its own reward." In all seriousness, even if the y combinator is practically useless in languages that don't have proper TCO (which is specced for ES7), it's a useful learning tool, is powerfully mind expanding, and can help to demonstrate the power of the λ-calculus.

Is the Y-combinator any more or less dependent on TCO than regular recursion? The Y combinator is useless in languages that already have builtin support for recursive functions.

No, Y is handy for defining nameless recursive functions, but it blows the stack even faster if you don't have TCO.

Re: Recursions without names: Introduction to the Y combinator in JavaScript

#27
post #25

Earlier quoted context omitted.

I did not know there was a Ruby to JS compiler. That's __really__ fascinating! Do you have plans to support Python any time soon?

I'd love to support python. If you find a way to evaluate python code in the browser, please let me know: viebel@gmail.com

Perhaps `skulpt`?

> Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser!

[0] https://github.com/skulpt/skulpt

Re: Recursions without names: Introduction to the Y combinator in JavaScript

#29
post #25

Earlier quoted context omitted.

I'd love to support python. If you find a way to evaluate python code in the browser, please let me know: viebel@gmail.com

Perhaps `skulpt`? > Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser! [0] https://github.com/skulpt/skulpt

Thanks a lot. Will try to integrate skulpt on klipse.

Re: Recursions without names: Introduction to the Y combinator in JavaScript

#30
post #22

To be fair, the article would be more aptly titled "Recursion without function names". In any recursion you need a way to reference the original function somehow. They're using a function parameter to accomplish that via indirection.

There are no names except function arguments. No 'x=...'

Please reread my post. The function parameter is the name.
Post reply on HN