RosettaCodeData/Task/Identity-matrix/JavaScript/identity-matrix-2.js
2016-12-05 22:15:40 +01:00

13 lines
247 B
JavaScript

(() => {
// idMatrix :: Int -> [[0 | 1]]
const idMatrix = n => Array.from({
length: n
}, (_, i) => Array.from({
length: n
}, (_, j) => i !== j ? 0 : 1));
// TEST
return idMatrix(5);
})();