From: walter a kehowski Date: 2005-08-07T18:56:10+09:00 Subject: Re: cartesian product "Giovanni Intini" wrote in message news:a32174e305080702273dc6accf@mail.gmail.com... > How would I create a function that will take list (array) of integers and > return their cartesian product? >You could do something like: > >a = [1, 2, 3] > >b = [] > >a.each do |elementone| > a.each do |elementtwo| > b << [elementone, elementtwo] > end >end > >That should do the trick (I haven't tested it though) Giovanni, Yes, that works. Another nuby question: How to make it a function? Such as cartprod(a,b) returning c? Walter