Skip to content

Instantly share code, notes, and snippets.

@therealklanni
Created August 10, 2015 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therealklanni/c04654cba04ad82caea3 to your computer and use it in GitHub Desktop.
Save therealklanni/c04654cba04ad82caea3 to your computer and use it in GitHub Desktop.
// 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' ]
@therealklanni
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment