I think this functionality is missing in Base.  But you can help
yourself by adapting the reverse! function:

julia> @less reverse!(collect(1:4))

On Mon, 2016-04-11 at 10:48, Thomas Magnusson <[email protected]> 
wrote:
> The in place reverse! function works of vectors:
>
> julia> a = collect(1:4);
> julia> reverse!(a)
> 4-element Array{Int64,1}:
> 4
> 3
> 2
> 1
>
> But, how should I do to reverse each row of a matrix, without resorting to 
> copy
> it ? The naïve way, seems to create a copy of the row before reversing:
>
> julia> a = collect(1:16);
> julia> b = reshape(a, (4,4))
> 4x4 Array{Int64,2}:
> 1 5  9 13
> 2 6 10 14
> 3 7 11 15
> 4 8 12 16
> julia> reverse!(b[1,:])
> 4-element Array{Int64,1}:
> 13
>  9
>  5
>  1
> julia> b
> 4x4 Array{Int64,2}:
> 1 5  9 13
> 2 6 10 14
> 3 7 11 15
> 4 8 12 16
>
>
> The original Matrix is unaffected. How should this be done ?

Reply via email to