Created
April 4, 2017 12:16
-
-
Save buntine/db00faedba04c9bc37366a55b10a8eed to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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