Robert Klemme <bob.news / gmx.net> wrote: > > Note that it might be more memory efficient to write a iteration method: > > def cartprod(a,b) > a.each {|ae| b.each {|be| yield ae, be}} > end > > Then you can also do this if needed > > c=[] > cartprod(a,b) {|x,y| c << [x,y]} > > If you just need every combination once the iteration approach is more > efficient. Or even better, if block_given? yield ae, be else (c ||= []) << ae, be end martin