B
bwv549
I need to turn some list of pairs into two arrays (the opposite of zipping two arrays together). There is a solution using "unfold" here (http://weblog.raganwald.com/2007/11/really-useful-anamorphisms-in-ruby.html) but that seems like more than what I want for this task.
I want to turn this:
[[1,2][3,4],[5,6]]
Into:
[[1,3,5], [2,4,6]]
What's the best ruby idiom for doing this task. Can it be generalized for triplets, quadruplets, etc.?
Or, if you use unfold, is there a particular gem you use and does it take amajor performance hit?
I want to turn this:
[[1,2][3,4],[5,6]]
Into:
[[1,3,5], [2,4,6]]
What's the best ruby idiom for doing this task. Can it be generalized for triplets, quadruplets, etc.?
Or, if you use unfold, is there a particular gem you use and does it take amajor performance hit?