Skip to content

Instantly share code, notes, and snippets.

@buntine
Created April 4, 2017 12:16
Show Gist options
  • Save buntine/db00faedba04c9bc37366a55b10a8eed to your computer and use it in GitHub Desktop.
Save buntine/db00faedba04c9bc37366a55b10a8eed to your computer and use it in GitHub Desktop.
function chunks(lst, size, step=1) {
function generate(from, to) {
if (from.length < step) {
return to.concat(from)
}
return generate(from.slice(step, from.length),
to.concat([from.slice(0, size)]))
}
return generate(lst, [])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment