在看 Julia 文档时,类函数对象中的这段代码该怎么理解呢
julia> struct Polynomial{R}
coeffs::Vector{R}
end
julia> function (p::Polynomial)(x)
v = p.coeffs[end]
for i = (length(p.coeffs)-1):-1:1
v = v*x + p.coeffs[i]
end
return v
end
julia> (p::Polynomial)() = p(5)
主要是
function (p::Polynomial)(x)
###
end
和
(p::Polynomial)() = p(5)
怎么理解?