On 1/31/07, Robert Klemme <shortcutter / googlemail.com> wrote:
>
> This occurred to me while lying sick in bed...
>
> robert@fussel /cygdrive/c/Temp
> $ ruby dd.rb
> [["foo", "bar", "baz", "biz"], [1, 2, 3, 4], [100, 200, 300, 400]]
> [["foo", 1, 100], ["bar", 2, 200], ["baz", 3, 300], ["biz", 4, 400]]
>
> robert@fussel /cygdrive/c/Temp
> $ cat dd.rb
>
> require 'enumerator'
> require 'pp'
>
> def transpose(a)
>    a.inject {|aa,b| aa.to_enum(:zip, b)}.inject([]){|aa,b| aa << b.flatten}
> end
>
> a = [
>    %w{foo bar baz biz},
>    [1,2,3,4],
>    [100,200,300,400],
> ]
>
> pp a, transpose(a)
>
>
> Did we have this before?
>
> Whatever...
>


a = [
   %w{foo bar baz biz},
   [1,2,3,4],
   [100,200,300,400],
]

a.transpose


Blessings,
TwP