From: Christopher Dicely Date: 2008-02-10T06:49:37+09:00 Subject: Re: Array Practice On Feb 9, 2008 12:50 PM, Adam Akhtar wrote: > a few people have mentioned some pretty concise solutions involving > map/collect selete find_all etc > > can someone give me an example of such a solution using the above. > > thanks > > > > -- > Posted via http://www.ruby-forum.com/. irb(main):067:0> def subpack(list) irb(main):068:1> list.uniq.map { |item| [item] * list.find_all { |val| val == item}.size } irb(main):069:1> end => nil irb(main):070:0> subpack [1,2,3,1,2,2,4,3,2,1] => [[1, 1, 1], [2, 2, 2, 2], [3, 3], [4]]