Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ASCII alias compose of (JuliaLang/julia#33573) #669

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,17 @@ Currently, the `@compat` macro supports the following syntaxes:

* `merge` methods with one and `n` `NamedTuple`s ([#29259]).

* Function composition `∘` now has an ASCII alias `compose` ([#33573]).

## Renaming

## New macros

## Other changes

* Function composition now supports multiple functions: `∘(f, g, h) = f ∘ g ∘ h`
and splatting `∘(fs...)` for composing an iterable collection of functions ([#33568]).

## New types

## Developer tips
Expand Down Expand Up @@ -127,3 +132,5 @@ includes this fix. Find the minimum version from there.
[#29749]: https://github.com/JuliaLang/julia/issues/29749
[#32628]: https://github.com/JuliaLang/julia/issues/32628
[#33129]: https://github.com/JuliaLang/julia/issues/33129
[#33568]: https://github.com/JuliaLang/julia/pull/33568
[#33573]: https://github.com/JuliaLang/julia/pull/33573
11 changes: 11 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ if VERSION < v"1.3.0-alpha.8"
Base.mod(i::Integer, r::AbstractUnitRange{<:Integer}) = mod(i-first(r), length(r)) + first(r)
end

# https://github.com/JuliaLang/julia/pull/33568
if VERSION < v"1.4.0-DEV.329"
Base.:∘(f, g, h...) = ∘(f ∘ g, h...)
end

# https://github.com/JuliaLang/julia/pull/33573
if VERSION < v"1.4.0-DEV.330"
export compose
const compose = ∘
end

include("deprecated.jl")

end # module Compat
9 changes: 9 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,13 @@ end
@test_throws DivideError mod(3, 1:0)
end

# https://github.com/JuliaLang/julia/pull/33568
# https://github.com/JuliaLang/julia/pull/33573
@testset "function composition" begin
@test ∘(x -> x-2, x -> x-3, x -> x+5)(7) == 7
fs = [x -> x[1:2], uppercase, lowercase]
@test ∘(fs...)("ABC") == "AB"
@test ∘(fs...) === compose(fs...)
end

nothing