# How can I make a lists of pairs out of two lists of triples?

I want to use this expression for my computation:

FoldList[vt[#2[], #1, #2[], b] &, v0,
Transpose[Join[{ea, cm}]]]


My problem now is that ea and cm is not only one list each it is a set of lists. How can I make a list of pairs out of these two set of lists?

For example:

ea = {{5, 6, 7}, {1, 2, 3}, {4, 8, 9}}
cm = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}


and i want a list of pairs of these lists but again in one list each like these:

eacm =
{{{5, 1}, {6, 2}, {7, 3}}, {{1, 4}, {2, 5}, {3, 6}}, {{4, 7}, {8, 8}, {9, 9}}}


My real lists are longer than those shown above. I have 720 numbers in each list.

## 5 Answers

Transpose[{ea, cm}, {3, 1, 2}]

Flatten[{ea, cm}, {{2}, {3}, {1}}]

• Ok but i will have the problem that i will have 10.000 lists i a row because i am doing a monte carlo simulation – user41673 Jul 16 '16 at 23:38
• sorry you couldn´t know but thank you very much for your solution – user41673 Jul 16 '16 at 23:39
• @user41673. I don't see how having two lists of 10000 triples invalidates this answer. – m_goldberg Jul 17 '16 at 0:10
• A very interesting explanation about Transpose second argument here -> 16968 – Murta Jul 18 '16 at 0:51

This is not an answer, but an extended comment on Hotoke's answer.

The OP seems to think Transpose isn't applicable when ea and cm are very long lists, say, of 10000 triples each. Perhaps the OP thinks it would be very slow is such a case. But actually it is very fast even for long lists, as I will demonstrate here.

SeedRandom;
With[{n = 10000, k = 12},
Module[{m, mt, t},
m = RandomInteger[42, {2, n, 3}];
t = AbsoluteTiming[mt = Transpose[m, {3, 1, 2}]][];
{t, Column[{#, mt[[#]]} & /@ RandomSample[Range[n], k]]}]] It still works well even if the sublists are longer. Here is example with 5-tuples.

SeedRandom;
With[{n = 10000, i = 5, k = 8},
Module[{m, mt, t},
m = RandomInteger[42, {2, n, i}];
t = AbsoluteTiming[mt = Transpose[m, {3, 1, 2}]][];
{t, Column[{#, mt[[#]]} & /@ RandomSample[Range[n], k]]}]] • That's some hardcore localization you got going on there ;)) – e.doroskevic Jul 17 '16 at 0:24
• @E.Doroskevic. I like to live clean :-) – m_goldberg Jul 17 '16 at 0:29

Does it fit your needs?

MapThread[List, {ea, cm}, 2]


Example

Transpose @ # & /@ Transpose[{ea, cm}]


Note: ea and cm same as in original post

Transpose second argument is like magic/cryptic for me. Here is another option using Map:

Map[Transpose, Transpose@{ea, cm}, {-3}]