Compute the cartesian product of an array.