Created
March 18, 2014 00:22
-
-
Save PuercoPop/9611220 to your computer and use it in GitHub Desktop.
Why?
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 repeat(x,n) { var a=[]; for (;n>0;n--) a.push(x); return a; } | |
// returns an array of the first `n` natural numbers | |
function range(n) { | |
return repeat('10', n+2).map(parseInt).slice(2).map(function(x) { | |
return x-2; | |
}); | |
} | |
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, NaN, NaN, NaN, NaN, NaN] | |
function repeat(x,n) { var a=[]; for (;n>0;n--) a.push(x); return a; } | |
// returns an array of the first `n` natural numbers | |
function range(n) { | |
return repeat('10', n+2).map(function(num) {return parseInt(num, 10);}).slice(2).map(function(x) { | |
return x-2; | |
}); | |
} | |
[8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment