what is the best idiom to perform the opposite of "zip"? (besides "unfold")

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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top