> 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)