Recursions without names: Introduction to the Y combinator in JavaScript
blog.klipse.tech
blog.klipse.tech
(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 :)
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.
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.
(lambda f: f(f))
(lambda fn: lambda n: 1 if n == 0 else (n * fn(fn)(n - 1)))
(5)If you find a way to evaluate python code in the browser, please let me know: viebel@gmail.com
> Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser!
Here's his JavaScirpt version: https://vimeo.com/45140590
RIP
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...
(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-functionsNo 'x=...'
Nerd -> meet article
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.
http://blog.klipse.tech/lambda/2016/08/10/y-combinator-app-j...
The Y combinator is useless in languages that already have builtin support for recursive functions.
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...