julia> f(x)=x+1
f (generic function with 1 method)
julia> isa(f, Function)
true
julia> typeof([f])
Vector{typeof(f)} (alias for Array{typeof(f), 1})
julia> f1(x)=x+1
f1 (generic function with 1 method)
julia> typeof([f,f1])
Vector{Function} (alias for Array{Function, 1})
f
has type typeof(f)
and a single-element vector chooses the most specific eltype typeof(f)
. You can use Function[f]
or Any[f]
to let more callables in.
3 Likes
Does this clear things up?
julia> promote_type(typeof(sin))
typeof(sin) (singleton type of function sin, subtype of Function)
julia> promote_type(typeof(sin), typeof(cos))
Function
3 Likes
Yes, thank you.
1 Like