Last active
August 29, 2015 14:17
-
-
Save pragmaticlogic/c6171ee75338f0398f19 to your computer and use it in GitHub Desktop.
Transpose array using ES6 syntax and Ramda.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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