* Jim Freeze <jim / freeze.org> [2005-07-28 23:05:12 +0900]:

> > > > [ [ "a", 1 ], [ "a", 2 ], ... [ "a", m ], [ "b", 1 ], ... [ n, 1 ],
> > > > ... [ n, m ] ]

>   irb(main):003:0> foo.collect { |f| f * bar }
>   => [[["a", 1], ["a", 2], ["a", 3]], [["b", 1], ["b", 2], ["b", 3]], [["c",
>   1], ["c", 2], ["c", 3]]]

To answer my own email, that is still not exactly what you
want, is it.

We need to flatten the first level.

  irb(main):004:0>  foo.collect { |f| f * bar }.inject([]) { |a,e| a.concat e }
  => [["a", 1], ["a", 2], ["a", 3], ["b", 1], ["b", 2], ["b", 3], ["c", 1],
  ["c", 2], ["c", 3]]

There, that's better, but ugly. Anyone got a cleaner way to flatten?

-- 
Jim Freeze