I have n short lists, and I want to construct the list of all the n-tuples that can be constructed taking the i'th element from the i'th list. Eg From
{1,2},{3},{4,5} I want to construct {{1,3,4},{1,3,5},{2,3,4},{2,3,5}}
I was hoping some combination of Outer and Flatten might do it, but I can't make that work. Any ideas?
To illustrate my difficulty,
In[151]:= Outer[List, {1}, {2}, {3, 4}] generates Out[151]= {{{{1, 2, 3}, {1, 2, 4}}}}
whereas
In[152]:= Outer[List, {1}, {2, 3}, {4}] generates Out[152]= {{{{1, 2, 4}}, {{1, 3, 4}}}}
Jim Simons