Is there an ASCII alias for the function composition operator in Julia, ∘
?
In general, is there a way to find ASCII/Unicode variants of operators?
julia> ∘
∘ (generic function with 2 methods)
^Tried this, ≈
for example has an alternative:
julia> ≈
isapprox (generic function with 8 methods)
For ∘
there is no alternative AFAICT. You can check by running:
julia> methods(∘)
# 3 methods for generic function "∘":
[1] ∘(f) in Base at operators.jl:874
[2] ∘(f, g) in Base at operators.jl:875
[3] ∘(f, g, h...) in Base at operators.jl:876
and opening the respective function definition (if you have a properly configured Julia installation just press e.g. 1 and then CTRL-Q) to get:
function ∘ end
∘(f) = f
∘(f, g) = (x...)->f(g(x...))
∘(f, g, h...) = ∘(f ∘ g, h...)
However, it is easy enough just to write:
const compose = ∘
and now you can use compose(f, g)
instead of f ∘ g
.
For ≈
and isapprox
it is the case that in the code isapprox
function is defined and then:
const ≈ = isapprox
definition is added in floatfuncs.jl.
You can use ComposedFunction(f, g)
on Julia 1.6 and above:
julia> ComposedFunction(-, exp)
(-) ∘ exp
Of course, it's a bit cumbersome, because you'd need to nest to compose more functions:
julia> ComposedFunction(-, ComposedFunction(exp, adjoint))
(-) ∘ (exp ∘ adjoint)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With