I'm trying to build a list of "phrases" using an array of word lists. I have an array that looks something like this:
[ [ 'big', 'small', 'wild' ],
[ 'brown', 'black', 'spotted' ],
[ 'cat', 'dog' ] ]
The first array is the first word in the resulting "phrase", the second array is the second word, and so on. The number of word lists is variable, it can be two lists of words or five lists. I'm having trouble converting that array to something that looks like this:
[ [ 'big', 'brown', 'cat' ],
[ 'big', 'brown', 'dog' ],
...
[ 'wild', 'spotted', 'dog'] ]
The order of the resulting array doesn't matter, but if the original array has three word lists, then the resulting nested arrays should be three words long.
I'm writing this in Javascript, but feel free to use whatever language you prefer as the recursion concept should be basically the same.