- #1
Shukie
- 95
- 0
I have these two lists:
L1 = {a, b, c}
L2 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
Now, my goal is to match up the first element of L1, which is a, to all the first elements of L2 and the second element of L1 (b) with all the second elements of L2 and the same with c. So I would get this:
L3 = {{a, 1}, {b, 2}, {c, 3}}, {{a, 4}, {b, 5}, {c, 6}}, {{a, 7}, {b, 8}, {c, 9}}
So L3 would consist of three separate lists. I can do this by using the command:
Table[Table[{L1[], L2[[k]][]}, {i, 1, 3}], {k, 1, 3}]
However, this takes up a lot of memory and almost freezes my computer. There must be a better way to do it?
L1 = {a, b, c}
L2 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
Now, my goal is to match up the first element of L1, which is a, to all the first elements of L2 and the second element of L1 (b) with all the second elements of L2 and the same with c. So I would get this:
L3 = {{a, 1}, {b, 2}, {c, 3}}, {{a, 4}, {b, 5}, {c, 6}}, {{a, 7}, {b, 8}, {c, 9}}
So L3 would consist of three separate lists. I can do this by using the command:
Table[Table[{L1[], L2[[k]][]}, {i, 1, 3}], {k, 1, 3}]
However, this takes up a lot of memory and almost freezes my computer. There must be a better way to do it?