Skip to content

Commit 85610bd

Browse files
committed
Docs: circshift!(::AbstractVector, ::Integer)
Closes #46016
1 parent 8a31ad6 commit 85610bd

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

base/abstractarray.jl

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3667,7 +3667,31 @@ function _keepat!(a::AbstractVector, m::AbstractVector{Bool})
36673667
deleteat!(a, j:lastindex(a))
36683668
end
36693669

3670-
## 1-d circshift ##
3670+
"""
3671+
circshift!(a::AbstractVector, shift::Integer)
3672+
3673+
Circulary shift, or rotate, the data in vector `a` by `shift` elements.
3674+
3675+
# Examples
3676+
3677+
```jldoctest
3678+
julia> circshift!([1, 2, 3, 4, 5], 2)
3679+
5-element Vector{Int64}:
3680+
4
3681+
5
3682+
1
3683+
2
3684+
3
3685+
3686+
julia> circshift!([1, 2, 3, 4, 5], -2)
3687+
5-element Vector{Int64}:
3688+
3
3689+
4
3690+
5
3691+
1
3692+
2
3693+
```
3694+
"""
36713695
function circshift!(a::AbstractVector, shift::Integer)
36723696
n = length(a)
36733697
n == 0 && return a

0 commit comments

Comments
 (0)