Skip to content

Commit

Permalink
Backport ∘ and ! from #17155 (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
TotalVerb authored and stevengj committed Jan 8, 2017
1 parent aa434e7 commit 8e198e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ Currently, the `@compat` macro supports the following syntaxes:
* `transcode` converts between UTF-xx string encodings in Julia 0.5 (as a lightweight
alternative to the LegacyStrings package), [#17323](https://github.com/JuliaLang/julia/pull/17323).

* `` (typically used infix as `f ∘ g`) for function composition can be used in 0.5 and earlier. [#17155](https://github.com/JuliaLang/julia/pull/17155)

* The method of `!` to negate functions (typically used as a unary operator, as in `!isinteger`) can be used in 0.5 and earlier. [#17155](https://github.com/JuliaLang/julia/pull/17155)

## Renamed functions

* `pointer_to_array` and `pointer_to_string` have been replaced with `unsafe_wrap(Array, ...)` and `unsafe_wrap(String, ...)` respectively.
Expand Down
7 changes: 7 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1739,4 +1739,11 @@ if VERSION < v"0.5.0-dev+5380"
end
end

# julia #17155 function composition and negation
if VERSION < v"0.6.0-dev.1883"
export
(f, g) = (x...)->f(g(x...))
@compat Base.:!(f::Function) = (x...)->!f(x...)
end

end # module
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1552,3 +1552,10 @@ let s = "Koala test: 🐨"
@test transcode(T, s) == transcode(T, s.data) == transcode(T, transcode(T, s))
end
end

# julia#17155, tests from Base Julia
@test (uppercasehex)(239487) == "3A77F"
let str = randstring(20)
@test filter(!isupper, str) == replace(str, r"[A-Z]", "")
@test filter(!islower, str) == replace(str, r"[a-z]", "")
end

0 comments on commit 8e198e9

Please sign in to comment.