From: Pit Capitain Date: 2002-08-01T03:19:55+09:00 Subject: Re: matrix challange On 1 Aug 2002, at 1:47, Daniel Bretoi wrote: > Sorry all, I actually checked for a matrix class, but I must have > missed it (. Anyway, what I would be interested in is how you would > approach the problem WITHOUT using the matrix class. I guess using one of my own libraries doesn't qualify either, but here it goes: require 'enumerables' a = [[1,2],[1,3],[2,4]] aT = Enumerables.new( *a ).collect { | x | x } ) p aT # => [[1, 1, 2], [2, 3, 4]] The Enumerables class takes a list of enumerables and traverses them in parallel. In this case, each row in the original matrix is one of those enumerables. You can find a similar class called SyncEnumerator in the ruby cvs at http://www.ruby-lang.org/~knu/cgi- bin/cvsweb.cgi/~checkout~/rough/lib/generator.rb?rev=1.6 Regards, Pit