MCPcopy Index your code
hub / github.com/trekhleb/javascript-algorithms / generateRecursively

Function generateRecursively

src/algorithms/math/matrix/Matrix.js:94–105  ·  view source on GitHub ↗
(recShape, recIndices)

Source from the content-addressed store, hash-verified

92 * @returns {Matrix}
93 */
94 const generateRecursively = (recShape, recIndices) => {
95 if (recShape.length === 1) {
96 return Array(recShape[0])
97 .fill(null)
98 .map((cellValue, cellIndex) => fill([...recIndices, cellIndex]));
99 }
100 const m = [];
101 for (let i = 0; i < recShape[0]; i += 1) {
102 m.push(generateRecursively(recShape.slice(1), [...recIndices, i]));
103 }
104 return m;
105 };
106
107 return generateRecursively(mShape, []);
108};

Callers 1

generateFunction · 0.85

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected