I want to get the Cartesian product of a
, b
, c
, d
:
a = ['a1']
b = ['b1', 'b2']
c = ['c1', 'c2', 'c3']
d = ['d1']
Here is code in Ruby:
e = [b, c, d]
print a.product(*e)
Output is:
[
["a1", "b1", "c1", "d1"],
["a1", "b1", "c2", "d1"],
["a1", "b1", "c3", "d1"],
["a1", "b2", "c1", "d1"],
["a1", "b2", "c2", "d1"],
["a1", "b2", "c3", "d1"]
]
Is there a similar package or function that could do product in Golang? This is just simplified version, in fact, the input data is like [['a1'], ['b1','b2'], ['c1','c2','c3],['d1'],['e1',...],...].