Skip to content

Instantly share code, notes, and snippets.

@fish2000
Created December 8, 2010 21:31
Show Gist options
  • Save fish2000/733950 to your computer and use it in GitHub Desktop.
Save fish2000/733950 to your computer and use it in GitHub Desktop.
JavaScript (approximate) implementation of Python xrange() builtin
function xrange(b0, b1, quanta) {
if (!quanta) { quanta = 1; }
if (!b1) { b1 = b0; b0 = 0; }
out = [];
for (var i = b0, idx = 0; i < b1; i += quanta, idx++) {
out[idx] = i;
}
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment