What's a simple way of computing the cartesian product of a list with itself n times?
That is, how can I define the function cartesianExp :: Int -> [a] -> [[a]].
For instance, the cartesian product of [1,2] with itself 3 times (n = 3) should be:
[
[1, 1, 1],
[1, 1, 2],
[1, 2, 1],
[1, 2, 2],
[2, 1, 1],
[2, 1, 2],
[2, 2, 1],
[2, 2, 2]
]