Concatenating scalar ranges into single row matrix

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

[0 1 2 3 4]

which I am trying to achieve with

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

However, the output I receive is

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?

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

[(1 - 1):0]'

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

1 Like

Thank you so much @baggepinnen

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

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

1 Like

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

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