gistlib
index.tsxfunction transposeMatrix(matrix) { return matrix[0].map((_, colIndex) => matrix.map(row => row[colIndex])); } // Example matrix const matrix = [[3, 2, 1], [5, 4, 3], ["a", "-", "-"]]; const transpose = transposeMatrix(matrix); console.log(transpose); 258 chars11 lines
function transposeMatrix(matrix) { return matrix[0].map((_, colIndex) => matrix.map(row => row[colIndex])); } // Example matrix const matrix = [[3, 2, 1], [5, 4, 3], ["a", "-", "-"]]; const transpose = transposeMatrix(matrix); console.log(transpose);
gistlibby LogSnag