From: lasitha Date: 2009-03-08T23:59:07+09:00 Subject: Re: how to un-ragged a 2D array? On Sun, Mar 8, 2009 at 3:43 AM, Phlip wrote: > Ktx! Now, on to Round Two! > > What if the array were even _more_ ragged?? > >   [   1     , >     [ 2, 3 ], >       4     , >     [ 5, 6 ], >       7     , >       8      ] > > > > In my case, the user-programmer can leave the second 1, 4, 7, & 8 out, as a > convenience, but the algorithm wants this... > >   [ [ 1, 1 ], >     [ 2, 3 ], >     [ 4, 4 ], >     [ 5, 6 ], >     [ 7, 7 ], >     [ 8, 8 ] ] > needs.map {|x, y| [x, y ||= x] } Solidarity, lasitha.