Nanyang Zhan wrote:
> well, then can anyone tell me which one is the best?
Unfortunately, these methods uses too much memory, storing the whole
cartesian product Array in memory even its elements are needed only one
at a time. One nicer alternative is the Cartesian module:
"The Cartesian module provide methods for the calculation of the
cartesian producted between two enumberable objects. It can also be
easily mixed in into any enumberable class, i.e. any class with
Enumerable module mixed in."
The Cartesian module is available at
http://rubyforge.org/projects/cartesian/
--
Posted via http://www.ruby-forum.com/.