[Numpy-discussion] how do I list all combinations
Wed Dec 26 14:45:34 CST 2007
On Dec 26, 2007 12:22 PM, Mathew Yeates <email@example.com> wrote:
> I have an arbitrary number of lists. I want to form all possible
> combinations from all lists. So if
> I want to return [["dog",1],["dog",2],["cat",1],["cat",2]]
> It's obvious when the number of lists is not arbitrary. But what if
> thats not known until runtime?
Would this work?
Make a function that takes two inputs (a list of lists and a list) and
returns a list of lists that contains all possible combinations.
Iterate through all lists by calling the function with the output of
the previous call (a list of lists) and the next list.
More information about the Numpy-discussion