Suppose I have two lists each of different sizes, e.g. toy case ListX = {x1, x2, x3}
and ListY = {y1, y2}
and all possible combinations of elements give rise to an element in another list ListZ = {z1, z2, z3, z4, z5, z6}
of length Length[ListX]
$ \times $ Length[ListY]
, i.e the tuple (x1, y1)
is associated with z1
, say.
How to merge all three lists such that I obtain the following combined list?
{{{x1, y1}, z1}, {{x1, y2}, z2}, {{x2, y1}, z3},
{{x2, y2}, z4}, {{x3, y1}, z5}, {{x3, y2}, z6}}
I've tried nested tables but I always generate additional items that I don't want. The actual lists I'm dealing with are of length O(50) such that the equivalent of ListZ
is of length O(2500).