From: walter a kehowski Date: 2005-08-09T16:01:09+09:00 Subject: Re: cartesian product "Gene Tani" wrote in message news:1123474109.033229.303310@o13g2000cwo.googlegroups.com... > can we merge 2 threads > > http://groups-beta.google.com/group/comp.lang.ruby/browse_frm/thread/baeb5e192b809bf3/608d3656142aeba6?lnk=st&q=lucky+stiff+group:comp.lang.ruby&rnum=6&hl=en#608d3656142aeba6 > Here's the nugget embedded in the thread: a=[1,2,3] b=[4,5,6] class Array def cartprod(b) self.inject(a=[]){|a,x| b.inject(a){|a,y| a << [x,y]}} end end p a.cartprod(b) Very nice! This is why we like Ruby! [IMHO] Walter Kehowski