Recursions without names: Introduction to the Y combinator in JavaScript
1–10 of 33 posts
Re: Recursions without names: Introduction to the Y combinator in JavaScript
#2Re: Recursions without names: Introduction to the Y combinator in JavaScript
#3 (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 combinator in JavaScript
#4Re: Recursions without names: Introduction to the Y combinator in JavaScript
#5http://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 combinator in JavaScript
#6For what purpose?
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 combinator in JavaScript
#7Obligatory '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 combinator in JavaScript
#8If 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 :)
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 combinator in JavaScript
#9Here's his JavaScirpt version: https://vimeo.com/45140590
RIP
Re: Recursions without names: Introduction to the Y combinator in JavaScript
#10A 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!
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...