Skip to content

Instantly share code, notes, and snippets.

@copperwall
Created April 10, 2020 01:11
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 copperwall/2246b745ad8494734eded70ff3fe1c56 to your computer and use it in GitHub Desktop.
Save copperwall/2246b745ad8494734eded70ff3fe1c56 to your computer and use it in GitHub Desktop.
function *range(min, max) {
while (min < max) {
yield min
min += 1
}
}
// Doesn't run out of memory
for (const num of range(1, 1000000000000000000)) {
console.log(num)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment