Last active
November 28, 2016 17:26
-
-
Save LeoAJ/5c086c45255d6bf9009c90826678a00b to your computer and use it in GitHub Desktop.
Generate `n` dimensional matrix
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
/** | |
* n = 3, offset = 1 | |
* [ | |
* [1, 2, 3], | |
* [4, 5, 6], | |
* [7, 8, 9] | |
* ] | |
*/ | |
const createMatrix = (n, offset = 0) => Array.from( | |
{ length: n }, (v1, i1) => Array.from( | |
{ length: n }, (v2, i2) => i1 * n + i2 + offset | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment