Created
August 10, 2015 02:16
-
-
Save therealklanni/c04654cba04ad82caea3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// pronounce Yl like "while" ;) | |
let Yl = Y(f => (g, i) => { | |
let r = g(i - 1) | |
return r !== false ? r : f(g, i - 1) | |
}) | |
// extremely contrived example using Yl | |
let people = [ 'Shannon', 'Joseph', 'Eric', 'Mike'] | |
Yl(i => { | |
log(people[i]) | |
people[i] = people[i] + i | |
return !i | |
}, people.length) | |
log(people) // => [ 'Shannon0', 'Joseph1', 'Eric2', 'Mike3' ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refer to The Mysterious Y-combinator