Skip to content

Instantly share code, notes, and snippets.

@vlas-ilya
Created October 9, 2015 15:48
Show Gist options
  • Save vlas-ilya/8a70e3a48f97345773a7 to your computer and use it in GitHub Desktop.
Save vlas-ilya/8a70e3a48f97345773a7 to your computer and use it in GitHub Desktop.
var transpose = function (matrix) {
var result = [];
for (var i = 0; i < matrix.length; i++) {
for (var j = 0; j < matrix[i].length; j++) {
if (result[j] == undefined) result[j] = [];
result[j][i] = matrix[i][j];
}
}
return result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment