Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,8 @@
function idMatrix(n) {
return Array.apply(null, new Array(n))
.map(function (x, i, xs) {
return xs.map(function (_, k) {
return i === k ? 1 : 0;
})
});
}

View file

@ -0,0 +1,16 @@
(() => {
// identityMatrix :: Int -> [[Int]]
const identityMatrix = n =>
Array.from({
length: n
}, (_, i) => Array.from({
length: n
}, (_, j) => i !== j ? 0 : 1));
// ----------------------- TEST ------------------------
return identityMatrix(5)
.map(JSON.stringify)
.join('\n');
})();