Last active
January 13, 2022 19:32
-
-
Save deebloo/713f67a0a2e55d49b1a80c3b3a96280e 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* windowed<T>(arr: T[], size: number) { | |
for (let i = 0; i < arr.length; i++) { | |
yield arr.slice(i, size + i); | |
} | |
} | |
let thing = windowed([0, 1, 2, 3], 2); | |
for (let [a, b] of thing) { | |
console.log(a, b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment