For example, if I had two lists, I'd do:
foreach (Item item1 in lists[0])
foreach (Item item2 in lists[1])
// Do something with item1 and item2
Or if I had three, I'd do
foreach (Item item1 in lists[0])
foreach (Item item2 in lists[1])
foreach (Item item3 in lists[2])
// Do something with item1, item2, and item3
but if I don't know at compile time how many lists are in the lists
collection, how can I easily iterate over every permutation?
A C# solution is ideal, but a solution in any language that demonstrates a suitable algorithm would be handy.
A good 2-dimensional example would be a list of columns and a list of rows on a spreadsheet, where I need to do processing on each cell. It's an n-dimensional problem, however.