Skip to content

Instantly share code, notes, and snippets.

@pragmaticlogic
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save pragmaticlogic/c6171ee75338f0398f19 to your computer and use it in GitHub Desktop.

Select an option

Save pragmaticlogic/c6171ee75338f0398f19 to your computer and use it in GitHub Desktop.
Transpose array using ES6 syntax and Ramda.js
var transpose = a => {
return R.map(c => {
return R.map(r => {
return r[c];
}, a);
}, R.keys(a[0]));
};
var a = [
[1,2,3,4],
[5,6,7,8],
[9,10,11,12]
];
transpose(a) //=> [[1,5,9],[2,6,10],[3,7,11],[4,8,12]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment