Skip to content

Commit

Permalink
Docs: circshift!(::AbstractVector, ::Integer) (#57539)
Browse files Browse the repository at this point in the history
Closes #46016

(cherry picked from commit b0323ab)
  • Loading branch information
barucden authored and KristofferC committed Mar 3, 2025
1 parent c5d0b67 commit c450cff
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3667,7 +3667,31 @@ function _keepat!(a::AbstractVector, m::AbstractVector{Bool})
deleteat!(a, j:lastindex(a))
end

## 1-d circshift ##
"""
circshift!(a::AbstractVector, shift::Integer)
Circularly shift, or rotate, the data in vector `a` by `shift` positions.
# Examples
```jldoctest
julia> circshift!([1, 2, 3, 4, 5], 2)
5-element Vector{Int64}:
4
5
1
2
3
julia> circshift!([1, 2, 3, 4, 5], -2)
5-element Vector{Int64}:
3
4
5
1
2
```
"""
function circshift!(a::AbstractVector, shift::Integer)
n = length(a)
n == 0 && return a
Expand Down

0 comments on commit c450cff

Please sign in to comment.