Skip to content

Instantly share code, notes, and snippets.

@tlareg
Last active February 19, 2018 14:45
Show Gist options
  • Save tlareg/f7a685986b9bdc054fbbd67035c89213 to your computer and use it in GitHub Desktop.
Save tlareg/f7a685986b9bdc054fbbd67035c89213 to your computer and use it in GitHub Desktop.
loop js lambda calculus y combinator
const loop = (cb, counter, maxCounter) =>
((x, i, max) => x(x, i, max))
(
(x, i, max) => (
cb(i),
(i++ < max) && x(x, i, max)
),
counter,
maxCounter
)
loop(i => console.log(i), 0, 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment