I have array
a = ["w1", "w2", "w3"]
How can I generate a new array with every combination of values? I need the output to look like this:
["w1", "w2", "w3", "w1 w1", "w1 w2", "w1 w3", "w2 w1", "w2 w2", "w2 w3", "w3 w1", "w3 w2", "w3 w3", "w1 w1 w1", "w1 w1 w2", "w1 w1 w3", "w1 w2 w1", "w1 w2 w2", "w1 w2 w3", "w2 w1 w1", "w2 w1 w2", "w2 w1 w2", "w2 w1 w3", "w2 w2 w1", "w2 w2 w2", "w2 w2 w3", "w2 w3 w1", "w2 w3 w2", "w2 w3 w3", "w3 w1 w1", "w3 w1 w2", "w3 w1 w3", "w3 w2 w1", "w3 w2 w2", "w3 w2 w3", "w3 w3 w1", "w3 w3 w2", "w3 w3 w2"]
Try code from Generate array of all combinations of an existing array
Result incorrect
"w1", "w2", "w3", "w1 w2", "w1 w3", "w2 w3", "w1 w2 w3"]