I have a list of lists such as [[0,1,2,3],[0,1,2,3], ..., [0,1,2,3]]
whose length is not know a priori.
My goal is to loop through all combinations of permutations of the [0,1,2,3]
sublists, each combination is a list of lists just like the original but where the order of some sublists have changed, eg. the second combination could be [[0,1,3,2],[0,1,2,3], ..., [0,1,2,3]]
and the third [[0,3,1,2],[0,1,2,3], ..., [0,1,2,3]]
. I will use each of those for something else.
I imagine it like one constructs the binary table, first one would loop through the permutations of the first sublist, keeping the rest of the sublists unmodified; once they are done, they advance one permutation in the second sublist and go back to the first and loop through it again, and so on. A simpler example:
| [0,1] | [0,1] | [0,1] |
| [0,1] | [0,1] | [1,0] |
| [0,1] | [1,0] | [0,1] |
| [0,1] | [1,0] | [1,0] |
| [1,0] | [0,1] | [0,1] |
| [1,0] | [0,1] | [1,0] |
| [1,0] | [1,0] | [0,1] |
| [1,0] | [1,0] | [1,0] |
I'm having trouble with this because the way I'm thinking about it looks like I would need to have a variable number of nested loops. I don't know how to think about it in terms of recursion because once recursion I would need to loop as well, and once I return
something that loop is lost.
Any help is appreciated.