# Combine 3 Lists in one with each other

I have a question about combining lists, I really tried it, but that's so hard for me. I'm a newbie.

I have this kind of a list:

a={{{2,3},{1,2},{3,5}},{{1,9},{1,5},{1,7}},{{10,10},{10,10},{20,20}}}


I need this kind of result:

res={{{2,3},{1,2},{3,5},{10,10},{20}},{{1,9},{1,5},{1,7},{10,10},{20}}}


My list can have 1000 of elements...

I would be thankful for your help

• Can you clarify what you want to achieve? For example, which of the input's 10s end up where in the desired output? Why should the {10,10},{20} in the output (twice) be grouped like that? – Jules Lamers Aug 22 '17 at 16:42
• These are 3 lists, which i already combine: a1= {{2,3},{1,2},{3,5}},{{1,9},{1,5},{1,7}} a2={{10,10},{10,10}} a3={{20,20}} – Mudy Fa Aug 22 '17 at 16:49
• What should happen if the 'third list' were {{10,11},{12,13},{20,21}} rather than {{10,10},{10,10},{20,20}}? – jjc385 Aug 22 '17 at 16:52
• @MudyFa But your a1 is not a list (missing {}s?), and your question does not involve a2 and a3 but rather a2~Join~a3... Could you be a bit more precise? – Jules Lamers Aug 22 '17 at 16:53
• @jjc385 this doesnt matter... its only importan to combine them in the right direction – Mudy Fa Aug 22 '17 at 16:54

If I assume some typos in your presentation, this seems to be another question about how to append columns.

a1 = {{{2, 3}, {1, 2}, {3, 5}}, {{1, 9}, {1, 5}, {1, 7}}};
a2 = {{10, 10}, {10, 10}};
a3 = {{20}, {20}};
Fold[MapThread[Append, {#1, #2}] &, {a1, a2, a3}] (* appends all*)
% // MatrixForm  (* display nicely *)

• Dont work, theres one coma mistake – Mudy Fa Aug 22 '17 at 17:54
• @MudyFa Please copy the entire code. It runs fine and produces your desired output. Note that my a3 is a correction of what you wrote: you said there were missing braces, so I added the braces needed for the format to make sense. – Alan Aug 22 '17 at 18:29
• No i Mean, there is a mistake in Fold, just try it!! – Mudy Fa Aug 23 '17 at 12:48
• @MudyFa You must have copied it wrong. It works as it should. If you are copying and pasting, that will sometimes lose end-of-lines. But the code is good. – Alan Aug 23 '17 at 13:23
• oh yes, it works, but there is something between, } and ] in the End of the Fold line something like this "^" – Mudy Fa Aug 23 '17 at 13:38
k = a[[3]][[All, 1]];
m = {Most@k};
n = {{Last@k}};

{Join[a[[1]], m, n], Join[a[[2]], m, n]}


{{{2, 3}, {1, 2}, {3, 5}, {10, 10}, {20}}, {{1, 9}, {1, 5}, {1, 7}, {10, 10}, {20}}}