From: "David A. Black" Date: 2009-07-14T22:33:04+09:00 Subject: Re: Elegant solution for inverting zip? Hi -- On Tue, 14 Jul 2009, Gregory Brown wrote: > Hi folks, > > I came across something I thought should have an obvious answer and > came up blank. I'm hoping folks could give me a nice solution to this > problem. > > Given the output below: > >>> a = [1,2,3,4].zip([5,6,7,8]) > => [[1, 5], [2, 6], [3, 7], [4, 8]] > > > I'd like to recover the original two arrays, something like > > unzip(a) #=> [[1,2,3,4],[5,6,7,8]] a.transpose, n'est-ce pas? David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Now available: The Well-Grounded Rubyist (http://manning.com/black2) Training! Intro to Ruby, with Black & Kastner, September 14-17 (More info: http://rubyurl.com/vmzN)