# Concatenating scalar ranges into single row matrix

**URL:** <https://discourse.julialang.org/t/concatenating-scalar-ranges-into-single-row-matrix/128326>\
**Category:** New to Julia\
**Tags:** matrices\
**Created:** [April 23, 2025, 10:29am UTC](https://discourse.julialang.org/t/concatenating-scalar-ranges-into-single-row-matrix/128326 "2025-04-23T10:29:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![keynescoefen](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@keynescoefen](https://discourse.julialang.org/u/keynescoefen)\
**Post date:** [April 23, 2025, 10:29am UTC](https://discourse.julialang.org/t/concatenating-scalar-ranges-into-single-row-matrix/128326/1 "2025-04-23T10:29:14Z")

</div>

Hello! I have a simple query about concatenating ranges into a row matrix. The desired output is

```julia
[0 1 2 3 4]

```

which I am trying to achieve with

```julia
[[(1 - 1):0]' [1:5-1]']

```

However, the output I receive is

```julia
1×2 adjoint(::Vector{UnitRange{Int64}}) with eltype Adjoint{Int64, UnitRange{Int64}}:
 [0;;] [1 2 3 4]

```

Can someone help me with the correct syntax?

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [April 23, 2025, 10:31am UTC](https://discourse.julialang.org/t/concatenating-scalar-ranges-into-single-row-matrix/128326/2 "2025-04-23T10:31:41Z")

</div>

```julia
julia> [((1 - 1):0)' (1:5-1)']
1×5 adjoint(::Vector{Int64}) with eltype Int64:
 0 1 2 3 4

# or

julia> [(1 - 1):0; 1:5-1]'
1×5 adjoint(::Vector{Int64}) with eltype Int64:
 0 1 2 3 4

```

This

```julia
[(1 - 1):0]'

```

is a vector containing a vector, which is not what you want

---

<div class="post-metadata">

**Author:** ![keynescoefen](https://avatars.discourse-cdn.com/v4/letter/k/d2c977/32.png) [@keynescoefen](https://discourse.julialang.org/u/keynescoefen)\
**Post date:** [April 23, 2025, 10:35am UTC](https://discourse.julialang.org/t/concatenating-scalar-ranges-into-single-row-matrix/128326/3 "2025-04-23T10:35:01Z")

</div>

Thank you so much @baggepinnen

May I please ask what the outer brackets in `( (1 - 1):0 )` achieve?

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [April 23, 2025, 10:35am UTC](https://discourse.julialang.org/t/concatenating-scalar-ranges-into-single-row-matrix/128326/4 "2025-04-23T10:35:56Z")

</div>

They make sure that the `'` applies to the range rather than to the last element of the range

---

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [April 23, 2025, 8:29pm UTC](https://discourse.julialang.org/t/concatenating-scalar-ranges-into-single-row-matrix/128326/5 "2025-04-23T20:29:18Z")

</div>

This form results in a Matrix{Int64}: and not a adjoint(::Vector{Int64}) .

```julia
[((1 - 1):0);; (1:5-1)']
[((1 - 1):2)';; (3:5-1)']

```
