I’d like to create a list of tuples from each value within a set of lists. The set of lists can be open, but for the example I have the following three lists of Strings.
L1: (one, two three)
L2: (a, b, c)
L3: (yes, no)
I would like to return a list of tuples, where in each tuple I have on element from each list. In this case, I will have 18 combinations (3 x 3 x 2)
T1: (one, a, yes)
T2: (one, a, no)
T3: (one, b, yes)
T4: (one, b, no)
T5: (one, c, yes)
T6: (one, c, no)
T7: (two, a, yes)
and so on. In this case we’re using Java.
List<List<String>> list = getInput();
List<List<String> tuples = combinations(list);
where getInput() returns my input (L1, L2, L3), and combinations creates my output (T1, T2, T3…)
This should be pretty easy with a recursive function. This is untested: