From: Olivier Date: 2006-12-14T19:44:37+09:00 Subject: Re: array and hash combine methods Le jeudi 14 d�cembre 2006 02:22, glen a �crit�: > Just thought I'd post a solution I came up with to finding > combinations (as in, permutations and combinations) of arrays. For > example, combining: > > [1,2] and [3,4,5] > > should return: > > [[1,3],[1,4],[1,5],[2,3],[2,4],[2,5]] > > which is easy enough. But I wanted something that combine several > arrays at once, ie: > > [[1,2],[3,4,5],[6,7]].combine > => [[1, 3, 6], [1, 3, 7], [1, 4, 6], [1, 4, 7], [1, 5, 6], [1, 5, 7], > [2, 3, 6], [2, 3, 7], [2, 4, 6], [2, 4, 7], [2, 5, 6], [2, 5, 7]] There is a Enumerable.combinations method in ruby facets which works like this. Take a look at : http://facets.rubyforge.org/api/core/classes/Enumerable.html#M000555 -- Olivier