4
$\begingroup$

Is there a way to append piecewise for example

list = {{1,2,3},{v,w,x},{a,b,c}}

Then append a list which

toappend = {{4,5,6,7,8},{y,z},{d}}

To get

list = {{1,2,3,4,5,6,7,8},{v,w,x,y,z},{a,b,c,d}}
$\endgroup$
10
$\begingroup$
Join[list, toappend, 2]
MapThread[Join, {list, toappend}]
Join @@@ Transpose@{list, toappend} (* thanks: AccidentalFourierTransform *)
Flatten /@ Transpose[{list, toappend}]
MapIndexed[Join[#, toappend[[#2[[1]]]]] &, list]
MapIndexed[Flatten[{#, toappend[[#2[[1]]]]}] &, list]
Flatten[{list[[#]], toappend[[#]]}]& /@ Range[Length @ list]

all give

{{1, 2, 3, 4, 5, 6, 7, 8}, {v, w, x, y, z}, {a, b, c, d}}

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.