Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hongbo-miao
Forked from femto113/transpose.js
Created November 1, 2016 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hongbo-miao/715893c8399aed02a4737da4fdfb951c to your computer and use it in GitHub Desktop.
Save hongbo-miao/715893c8399aed02a4737da4fdfb951c to your computer and use it in GitHub Desktop.
one line transpose for 2-dimensional Javascript arrays
function transpose(a)
{
return a[0].map(function (_, c) { return a.map(function (r) { return r[c]; }); });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment