# Vcat without allocations?

**URL:** <https://discourse.julialang.org/t/vcat-without-allocations/19999>\
**Category:** New to Julia\
**Created:** [January 23, 2019, 6:36pm UTC](https://discourse.julialang.org/t/vcat-without-allocations/19999 "2019-01-23T18:36:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)\
**Post date:** [January 23, 2019, 6:36pm UTC](https://discourse.julialang.org/t/vcat-without-allocations/19999/1 "2019-01-23T18:36:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 23, 2019, 6:38pm UTC](https://discourse.julialang.org/t/vcat-without-allocations/19999/2 "2019-01-23T18:38:53Z")

</div>

> **[GitHub - JuliaArrays/LazyArrays.jl: Lazy arrays and linear algebra in Julia](https://github.com/JuliaArrays/LazyArrays.jl)**
>
> Lazy arrays and linear algebra in Julia. Contribute to JuliaArrays/LazyArrays.jl development by creating an account on GitHub.
