Skip to content

Commit

Permalink
Merge pull request #445 from JuliaLang/aa/more-0.7
Browse files Browse the repository at this point in the history
Add invpermute! and a pairs method for replace
  • Loading branch information
ararslan authored Jan 3, 2018
2 parents 7a92e17 + eb60a6a commit 7b874aa
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ Currently, the `@compat` macro supports the following syntaxes:

* `Some{T}` wraps `T` to signify that a result of `T<:Void` is expected ([#23642]).

* `replace` accepts a pair of pattern and replacement, with the number of replacements as
a keyword argument ([#25165]).

## Renaming


Expand Down Expand Up @@ -266,6 +269,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `unshift!` and `shift!` are now `pushfirst!` and `popfirst!` ([#25100]).

* `ipermute!` is now `invpermute!` ([#25168]).

## New macros

* `@__DIR__` has been added ([#18380])
Expand Down Expand Up @@ -424,3 +429,5 @@ includes this fix. Find the minimum version from there.
[#25100]: https://github.com/JuliaLang/julia/issues/25100
[#25102]: https://github.com/JuliaLang/julia/issues/25102
[#25162]: https://github.com/JuliaLang/julia/issues/25162
[#25165]: https://github.com/JuliaLang/julia/issues/25165
[#25168]: https://github.com/JuliaLang/julia/issues/25168
11 changes: 11 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,17 @@ end
export pushfirst!, popfirst!
end

# 0.7.0-DEV.3173
@static if !isdefined(Base, :invpermute!)
const invpermute! = ipermute!
export invpermute!
end

@static if VERSION < v"0.7.0-DEV.3172"
Base.replace(s::AbstractString, pat_rep::Pair; count::Integer=typemax(Int)) =
replace(s, first(pat_rep), last(pat_rep), count)
end

include("deprecated.jl")

end # module Compat
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,13 @@ let coolvec = [1,2,3]
@test popfirst!(coolvec) == 0
end

# 0.7.0-DEV.3173
@test invpermute!(permute!([1, 2], 2:-1:1), 2:-1:1) == [1, 2]

# 0.7.0-DEV.3172
@test replace("abcb", "b"=>"c") == "accc"
@test replace("abcb", "b"=>"c", count=1) == "accb"

if VERSION < v"0.6.0"
include("deprecated.jl")
end
Expand Down

0 comments on commit 7b874aa

Please sign in to comment.