From: Robert Dober Date: 2009-06-15T21:21:30+09:00 Subject: Re: formatting a listing On Mon, Jun 15, 2009 at 2:12 PM, George George wrote: > Robert Dober wrote: >> On Mon, Jun 15, 2009 at 12:46 PM, George >> George wrote: >>> 3 >>> any ideas? >>> thanks >> >> If this is a homework assignement I am terribly sorry, but I cannot >> know. >> >> puts DATA.inject( [  [] ] ){ | ary, ele | >>   ele.strip.empty? ? ary << [] : ary.last << ele.to_i # or ele.chomp >> if you prefer >>   ary >> } >> .reject( &:empty? )  # .map( &:join, ", " ) is not standard Ruby >> .map{ | eles | eles.join( ", " )} >> >> __END__ >> 1 >> 2 >> >> 42 >> 44 >> 46 >> >> 2000 >> >> HTH >> Robert > > Thank so much for pointing the way: And this is not assignment! :) Am > working on some huge datasets that run in to up to 20 000 columns and > was looking for an easy way of creating the columns. If you have perf problems do not worry, inject is slow replace inject(x){ |a,e| } with loc = x each { |e| loc << e # e.g } loc # you will have a speedup of 2~3