Skip to content

Commit

Permalink
Docs: circshift!(::AbstractVector, ::Integer)
Browse files Browse the repository at this point in the history
  • Loading branch information
barucden committed Feb 26, 2025
1 parent 8a31ad6 commit 303df4d
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 303df4d

Please sign in to comment.