# Joining each element of second tuples to the end of each element of the first tuples [closed]

How can I generate a new tuples by joining each element of tup3 to tup1?
For example joining {0,1,1,1,0,-1} from tup1 and {d,0,1} from tup3 to generate {0,1,1,1,0,-1,d,0,1}

tup1 = Tuples@{{0, 1}, {-1, 0, 1}, {-1, 0, 1}, {0, 1}, {-1, 0,
1}, {-1, 0, 1}};
tup2 = Tuples[{{0, 1, -1}, {0, 1, -1}}];
tup3 = tup2 /. {a_, b_} :> {d, a, b}
• Join @@@ Tuples[{tup1, tup3}]? – kglr Apr 4 at 19:37
• @kglr well, that works. Do you have any method to get that directly from tup1 and tup2? Above I have to add one more step to add tup3 to add the "d". – anhnha Apr 4 at 19:39
• try Join @@@ Tuples[{tup1, {{d}}, tup2}] – kglr Apr 4 at 19:48

tup4a = Join @@@ Tuples[{tup1, tup3}];
tup4a // Short
{{0,-1,-1,0,-1,-1,d,0,0},{0,-1,-1,0,-1,-1,d,0,1},<<2912>>,
{1,1,1,1,1,1,d,-1,1},{1,1,1,1,1,1,d,-1,-1}}
tup4b = Distribute[{tup1, tup3}, List, List, List, Join];

tup4a == tup4b
True

"to get that directly from tup1 and tup2":

tup4c = Join @@@ Tuples[{tup1, {{d}}, tup2}];

tup4a == tup4c
True
• well, that looks simple now just apply Join at level 1 but I couldn't think of. – anhnha Apr 4 at 19:53