Skip to content

Commit

Permalink
add news/docs for JuliaLang#34524: 2-arg splice! on arbitrary index i…
Browse files Browse the repository at this point in the history
…terables (JuliaLang#34897)
  • Loading branch information
rfourquet authored and ravibitsgoa committed Apr 6, 2020
1 parent 035eed6 commit 29f57b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ New library features
* `isapprox` (or ``) now has a one-argument "curried" method `isapprox(x)` which returns a function, like `isequal` (or `==`)` ([#32305]).
* `Ref{NTuple{N,T}}` can be passed to `Ptr{T}`/`Ref{T}` `ccall` signatures ([#34199])
* `accumulate`, `cumsum`, and `cumprod` now support `Tuple` ([#34654]).

* In `splice!` with no replacement, values to be removed can now be specified with an
arbitrary iterable (instead of a `UnitRange`) ([#34524]).

Standard library changes
------------------------
Expand Down
11 changes: 7 additions & 4 deletions base/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1393,17 +1393,20 @@ function splice!(a::Vector, i::Integer, ins=_default_splice)
end

"""
splice!(a::Vector, range, [replacement]) -> items
splice!(a::Vector, indices, [replacement]) -> items
Remove items in the specified index range, and return a collection containing
Remove items at specified indices, and return a collection containing
the removed items.
Subsequent items are shifted left to fill the resulting gap.
Subsequent items are shifted left to fill the resulting gaps.
If specified, replacement values from an ordered collection will be spliced in
place of the removed items.
place of the removed items; in this case, `indices` must be a `UnitRange`.
To insert `replacement` before an index `n` without removing any items, use
`splice!(collection, n:n-1, replacement)`.
!!! compat "Julia 1.5"
Prior to Julia 1.5, `indices` must always be a `UnitRange`.
# Examples
```jldoctest
julia> A = [-1, -2, -3, 5, 4, 3, -1]; splice!(A, 4:3, 2)
Expand Down

0 comments on commit 29f57b8

Please sign in to comment.