Created
May 25, 2011 12:30
-
-
Save xulapp/990865 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 range(start, end, step) { | |
| if (arguments.length < 1) | |
| throw new TypeError('range expected at least 1 arguments, got 0'); | |
| if (arguments.length < 2) | |
| end = start, start = 0; | |
| if (arguments.length < 3) | |
| step = 1; | |
| start |= 0, end |= 0, step |= 0; | |
| if (!step) | |
| throw new Error('range() step argument must not be zero'); | |
| if (step < 0) | |
| for (var i = start; end < i; i += step) | |
| yield i; | |
| else | |
| for (var i = start; i < end; i += step) | |
| yield i; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment