Filling arrays in rows

Hi,
Could someone please help me to figure out how a matrix could be filled in rows. So if I give some numbers with dimension then they would form a 2 dimensional array but it will start filling from the first row, then second and so on. I have seen the reshape command. So for example

reshape(collect(1:8), 2, 4)
2×4 Array{Int64,2}:
1 3 5 7
2 4 6 8

but I want something like

2×4 Array{Int64,2}:
1 2 3 4
5 6 7 8

I know I can create array bu just giving each rows, for example, like this

2×4 Array{Int64,2}:
1 2 3 4
5 6 7 8

But is there any a bit more automatic way?

Thanks s a lot for the help

Try

julia> reshape(collect(1:8), 4, 2)'
2×4 Adjoint{Int64,Array{Int64,2}}:
 1  2  3  4
 5  6  7  8

I.e., create the transposed array and then transpose it.

Or even put the collect outside so you end up with just a regular array and not an Adjoint.

julia> collect(reshape(1:8, 4, 2)')
2×4 Array{Int64,2}:
 1  2  3  4
 5  6  7  8
1 Like

This was so easy, thanks a lot,… so you fill the columns and then transpose, feel like dumb question now.

Thanks also, now I know two ways