RosettaCodeData/Task/Matrix-transposition/JavaScript/matrix-transposition-3.js

18 lines
326 B
JavaScript
Raw Permalink Normal View History

2016-12-05 22:15:40 +01:00
(() => {
'use strict';
// transpose :: [[a]] -> [[a]]
2018-06-22 20:57:24 +00:00
const transpose = xs =>
2019-09-12 10:33:56 -07:00
xs[0].map((_, iCol) => xs.map(row => row[iCol]));
2016-12-05 22:15:40 +01:00
2019-09-12 10:33:56 -07:00
// TEST -----------------------------------------------
return(
transpose([
[1, 2],
[3, 4],
[5, 6]
])
);
2016-12-05 22:15:40 +01:00
})();