On Mar 11, 5:06 am, David Palm <dvd... / gmail.com> wrote:

> I need all the unique combinations of each product from the first group with each of the second. For example:
> given: [ [:p1, :p2], [:p3, p4] ]
> I need to obtain: [ [:p1, :p3], [:p1, :p4], [:p2, :p3], [:p2, :p4] ]
>
> Given: [ [:p1], [:p2, :p3, :p4] ]
> I need: [ [:p1, :p2], [:p1, :p3], [:p1, :p4] ]

p [[1,2],[3,4]].inject([[]]){|old,lst|
  lst.inject([]){|new,e| new + old.map{|c| c.dup << e}}}