Created
May 3, 2017 17:27
-
-
Save coproduto/ef71be974deec8d57acaf64214890433 to your computer and use it in GitHub Desktop.
This file contains 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 rangeFromZero(end) { | |
return [...Array(end).keys()]; | |
} | |
function exclusiveRange(start, end) { | |
if (end === undefined) { | |
return rangeFromZero(start); | |
} | |
if (end > start) { | |
return rangeFromZero(end - start).map(x => x + start); | |
} | |
return []; | |
} | |
function inclusiveRange(start, end) { | |
if (end === undefined) { | |
return rangeFromZero(start+1); | |
} | |
return exclusiveRange(start, end+1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment