juliafunction-composition

ASCII alternative to the Julia function composition (∘) operator?


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)

Solution

  • 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.