Vcat without allocations?

I have two vectors x1 and x2 and would like to loop over the elements in vcat(x1,x2). In particular, I want to sum over the two adjacent elements.

How can I do that without explicitly creating x = vcat(x1,x2) and looping over the elements in x?

In particular, is there a simple solution for the case when there is also a x3 and more, and when I want to sum over q elements.

/Paul S

1 Like