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

Expose ComposedFunction as a public API #37517

Merged
merged 15 commits into from
Sep 24, 2020
Prev Previous commit
Next Next commit
fix ComposedFunction doctest
  • Loading branch information
jw3126 committed Sep 21, 2020
commit 3420ac6942e0e97e6e458c13786e982aef51468b
8 changes: 4 additions & 4 deletions base/operators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -871,24 +871,24 @@ julia> fs = [
julia> ∘(fs...)(3)
3.0
```
See also [`Base.ComposedFunction`](@ref).
See also [`ComposedFunction`](@ref).
"""
function ∘ end

"""
Base.ComposedFunction{Outer,Inner} <: Function
ComposedFunction{Outer,Inner} <: Function

Represents the composition of two callable objects `outer::Outer` and `inner::Inner`. That is
```julia
ComposedFunction(outer, inner)(args...; kw...) === outer(inner(args...; kw...))
```
The preferred way to construct instance of `ComposedFunction` is to use the composition operator [`∘`](@ref):
```jldoctest
julia> sin ∘ cos === Base.ComposedFunction(sin, cos)
julia> sin ∘ cos === ComposedFunction(sin, cos)
true

julia> typeof(sin∘cos)
Base.ComposedFunction{typeof(sin), typeof(cos)}
ComposedFunction{typeof(sin), typeof(cos)}
```
The composed pieces are stored in the fields of `ComposedFunction` and can be retrieved as follows:
```jldoctest
Expand Down