Skip to content

Commit 8e198e9

Browse files
TotalVerbstevengj
authored andcommitted
Backport ∘ and ! from #17155 (#298)
1 parent aa434e7 commit 8e198e9

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ Currently, the `@compat` macro supports the following syntaxes:
9595
* `transcode` converts between UTF-xx string encodings in Julia 0.5 (as a lightweight
9696
alternative to the LegacyStrings package), [#17323](https://github.com/JuliaLang/julia/pull/17323).
9797

98+
* `` (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)
99+
100+
* 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)
101+
98102
## Renamed functions
99103

100104
* `pointer_to_array` and `pointer_to_string` have been replaced with `unsafe_wrap(Array, ...)` and `unsafe_wrap(String, ...)` respectively.

src/Compat.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,4 +1739,11 @@ if VERSION < v"0.5.0-dev+5380"
17391739
end
17401740
end
17411741

1742+
# julia #17155 function composition and negation
1743+
if VERSION < v"0.6.0-dev.1883"
1744+
export
1745+
(f, g) = (x...)->f(g(x...))
1746+
@compat Base.:!(f::Function) = (x...)->!f(x...)
1747+
end
1748+
17421749
end # module

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,3 +1552,10 @@ let s = "Koala test: 🐨"
15521552
@test transcode(T, s) == transcode(T, s.data) == transcode(T, transcode(T, s))
15531553
end
15541554
end
1555+
1556+
# julia#17155, tests from Base Julia
1557+
@test (uppercasehex)(239487) == "3A77F"
1558+
let str = randstring(20)
1559+
@test filter(!isupper, str) == replace(str, r"[A-Z]", "")
1560+
@test filter(!islower, str) == replace(str, r"[a-z]", "")
1561+
end

0 commit comments

Comments
 (0)