In-place reverse!

In-place reverse! is defined for vectors.
Does it make sense to have reverse! for general arrays with other dimensions?
In particular, I thought it might useful for matrices?

This depends on your use case; since reverse supports this it would be a natural extension. I guess it’s just that no one got around to writing it yet.

Uh?

julia> A = rand(2,2)
2×2 Matrix{Float64}:
 0.664925  0.689702
 0.987743  0.960874

julia> reverse!(A)
2×2 Matrix{Float64}:
 0.960874  0.987743
 0.689702  0.664925

julia> A
2×2 Matrix{Float64}:
 0.960874  0.987743
 0.689702  0.664925

Edit: this is Julia v1.6, probably not available in v1.5-. This is mentioned in NEWS.md for Julia v1.6.

4 Likes

Yep, doesn’t work on 1.5.2.

1 Like

Ha, ha. Thanks for that!