ASCII 替代 Julia 函数组合 (∘) 运算符?

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

Julia 中是否有函数组合运算符的 ASCII 别名,

一般来说,有没有办法找到运算符的 ASCII/Unicode 个变体?

julia> ∘
∘ (generic function with 2 methods)

^试过这个,例如有一个替代方案:

julia> ≈
isapprox (generic function with 8 methods)

对于 没有替代 AFAICT。您可以通过 运行:

查看
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

并打开相应的函数定义(如果您有正确配置的 Julia 安装,只需按例如 1 然后 CTRL-Q)获得:

function ∘ end
∘(f) = f
∘(f, g) = (x...)->f(g(x...))
∘(f, g, h...) = ∘(f ∘ g, h...)

然而,只要这样写就足够容易了:

const compose = ∘

现在您可以使用 compose(f, g) 而不是 f ∘ g

对于isapprox是这样的,在代码中定义了isapprox函数然后:

const ≈ = isapprox

在floatfuncs.jl中添加了定义。