From: Simon Strandgaard <0bz63fz3m1qt3001@...> Date: 2003-05-26T08:16:47+09:00 Subject: Re: Array# method like shape in Python? On Sun, 25 May 2003 23:47:54 +0000, Phlip wrote: > What's the equivalent in the (vastly superior) language Ruby? How does one > unflatten? How about ??? > ruby flat.rb [[1, 1, 1], [2, 2], [3, 3, 3, 3]] > > cat flat.rb class Array def shape(*n) data = self res = [] n.each do |count| res << data.slice!(0, count) end res end end p [1, 1, 1, 2, 2, 3, 3, 3, 3].shape(3, 2, 4) > -- Simon Strandgaard