News for hackers. Stuff that matters.
Re:Recursions without names: Introduction to the Y combinato... by nightcracker on Thursday August 11, 2016 @07:30PM (#12272451)
If I'm not mistaken, this isn't the full Y combinator yet. It's a partial step towards deriving the full Y combinator.

    (f => (x => x(x))(y => f(x => y(y)(x))))
    (func => n => (n === 0) ? 1 : (n * func(n - 1)))
    (19)
Notice that the ugly func(func)(n-1) recursive call with the proper Y combinator simply became func(n-1).

The full Y combinator is also vastly more mystical and less obvious than the partial step :)

Re:Recursions without names: Introduction to the Y combinato... by viebel on Friday August 12, 2016 @01:59AM (#12273631)
The full Y combinator is presented in the sequel of the current article: http://blog.klipse.tech/lambda/2016/08/10/pure-y-combinator-...
Re:Recursions without names: Introduction to the Y combinato... by thethirdone on Thursday August 11, 2016 @11:11PM (#12273187)
> The full Y combinator is also vastly more mystical and less obvious than the partial step :)

The full Y conbinator simply binds func to func(func) as seen in `(y => f(x => y(y)(x))))`, an easy jump to make and pretty easy to understand.

Re:Recursions without names: Introduction to the Y combinato... by louthy on Thursday August 11, 2016 @09:41PM (#12272947)
Obligatory 'To Dissect a Mockingbird' link:

http://dkeenan.com/Lambda/index.htm

If you have never read this before, then I highly recommend it. It's a beautiful way to picture combinators.

Re:Recursions without names: Introduction to the Y combinato... by qwertyuiop924 on Thursday August 11, 2016 @09:54PM (#12272971)
Indeed. It's by far best explanation of the concept that I've seen, and it, along with some of Matt Might's posts, helped me gain a deeper appreciation for concepts like Church Encoding, and λ-calculus in general.
Re:Recursions without names: Introduction to the Y combinato... by prashnts on Friday August 12, 2016 @04:43AM (#12274146)
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)
Re:Recursions without names: Introduction to the Y combinato... by viebel on Friday August 12, 2016 @05:49AM (#12274338)
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...
Re:Recursions without names: Introduction to the Y combinato... by prashnts on Friday August 12, 2016 @07:53AM (#12274821)
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 combinato... by viebel on Friday August 12, 2016 @08:49AM (#12275136)
I'd love to support python.

If you find a way to evaluate python code in the browser, please let me know: [email protected]

Re:Recursions without names: Introduction to the Y combinato... by prashnts on Friday August 12, 2016 @09:48AM (#12275558)
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 combinato... by viebel on Friday August 12, 2016 @11:20AM (#12276390)
Thanks a lot. Will try to integrate skulpt on klipse.
Re:Recursions without names: Introduction to the Y combinato... by usagimaru on Friday August 12, 2016 @12:00AM (#12273321)
Jim Weirich had a good couple talks about building a Y combinator in a couple languages.

Here's his JavaScirpt version: https://vimeo.com/45140590

RIP

Re:Recursions without names: Introduction to the Y combinato... by ChicagoBoy11 on Thursday August 11, 2016 @07:27PM (#12272436)
A question about the klipse plugin: Does code inside it have access to DOM elements just as javascript running on the console would? Would be a fantastic addition that could really make developing an interactive coding exercise for kids learning about the web a breeze!
Re:Recursions without names: Introduction to the Y combinato... by viebel on Friday August 12, 2016 @01:55AM (#12273620)
Indeed, the klipse plugin has access to DOM elements.

What ideas do you have for kids?

I have tried to do something for kids here: kids.klipse.tech

The klipse plugin concept is explained in details:

1. http://blog.klipse.tech/javascript/2016/06/20/blog-javascrip...

2. https://github.com/viebel/klipse

Re:Recursions without names: Introduction to the Y combinato... by millstone on Friday August 12, 2016 @02:34AM (#12273720)
The code samples fail in Safari. The first one prints "SyntaxError: Unexpected token '>'".
Re:Recursions without names: Introduction to the Y combinato... by Sacho on Friday August 12, 2016 @05:55AM (#12274360)
Your version of Safari most likely lacks support for ES6 features like arrow functions[0], you could use babel[1] to transpile the code to ES5:

  (function (f) {
    return f(f);
  })(function (func) {
    return function (n) {
      return n === 0 ? 1 : n * func(func)(n - 1);
    };
  })(19);

[0] http://caniuse.com/#feat=arrow-functions

[1] https://babeljs.io/repl/

Re:Recursions without names: Introduction to the Y combinato... by dsego on Friday August 12, 2016 @04:21AM (#12274075)
You need Safari Technology Preview for ES6 support.
Re:Recursions without names: Introduction to the Y combinato... by hughbetcha on Friday August 12, 2016 @07:06AM (#12274626)
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.
Re:Recursions without names: Introduction to the Y combinato... by viebel on Friday August 12, 2016 @07:30AM (#12274716)
There are no names except function arguments.

No 'x=...'

Re:Recursions without names: Introduction to the Y combinato... by hughbetcha on Friday August 12, 2016 @11:54AM (#12276623)
Please reread my post. The function parameter is the name.
Re:Recursions without names: Introduction to the Y combinato... by viebel on Friday August 12, 2016 @12:04PM (#12276691)
Do you know a language without argument names?
Re:Recursions without names: Introduction to the Y combinato... by hughbetcha on Friday August 12, 2016 @03:03PM (#12277983)
You're missing the point. Nevermind.
Re:Recursions without names: Introduction to the Y combinato... by jomamaxx on Friday August 12, 2016 @07:44AM (#12274784)
Kitten -> meet laser pointer

Nerd -> meet article

Re:Recursions without names: Introduction to the Y combinato... by furhxbbd on Thursday August 11, 2016 @08:57PM (#12272831)
For what purpose?
Re:Recursions without names: Introduction to the Y combinato... by qwertyuiop924 on Thursday August 11, 2016 @09:50PM (#12272963)
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.

Re:Recursions without names: Introduction to the Y combinato... by viebel on Friday August 12, 2016 @01:56AM (#12273622)
There is a practical application for recursive memoization:

http://blog.klipse.tech/lambda/2016/08/10/y-combinator-app-j...

Re:Recursions without names: Introduction to the Y combinato... by gohrt on Friday August 12, 2016 @02:27AM (#12273702)
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.

Re:Recursions without names: Introduction to the Y combinato... by viebel on Friday August 12, 2016 @04:45AM (#12274154)
Not useless, almost useless:

You can do elegant recursive memoization with the Y combinator as explained here http://blog.klipse.tech/lambda/2016/08/10/y-combinator-app-j...

Re:Recursions without names: Introduction to the Y combinato... by qwertyuiop924 on Friday August 12, 2016 @08:52AM (#12275161)
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 combinato... by kristianp on Friday August 12, 2016 @02:23AM (#12273689)
Re:Recursions without names: Introduction to the Y combinato... by agumonkey on Friday August 12, 2016 @10:22AM (#12275851)
Implementing a linguistic trait when not built in. Next: continuations. Next: prolog.
Re:Recursions without names: Introduction to the Y combinato... by pjssjppjs on Sunday August 21, 2016 @03:51PM (#12332440)