Skip to content

Instantly share code, notes, and snippets.

@git2samus
Created May 22, 2012 20:07
Show Gist options
  • Select an option

  • Save git2samus/2771324 to your computer and use it in GitHub Desktop.

Select an option

Save git2samus/2771324 to your computer and use it in GitHub Desktop.
function range() {
switch (arguments.length) {
case 1:
var start=0, stop=arguments[0], step=1;
break;
case 2:
var start=arguments[0], stop=arguments[1], step=1;
break;
case 3:
var start=arguments[0], stop=arguments[1], step=arguments[2];
break;
}
return function() {
if (start < stop) {
var current = start;
start += step;
return current;
};
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment