julia> (2.1,) isa Tuple{Float64}
true
julia> (2.1,3.0) isa Tuple{Float64}
false
So Tuple{V} can only have a single element.
This works, but only for length-2 tuples:
function fcn(xvec::AbstractVector{T}, ytup::Tuple{V,V}, ztup::Tuple{V,V}) where {T <: Real, V <: AbstractVector{T}}
@show typeof(xvec)
@show typeof(ytup)
@show typeof(ztup)
end
To make this example work as you intended, you probably want to use either Tuple{Vararg{V}}, or NTuple{N,V} where N, which will work for tuples of an arbitrary number of elements <:V.
function fcn(TupVecs::NTuple{N, V}) where {N, V <: AbstractVector}
x = 1
for nVec ā eachindex(TupVecs)
y = TupVecs[nVec][2]
println(y)
end
end
function fcn(TupFcns::NTuple{N, F}) where {N, F <: Function}
x = 1
for nFcn ā eachindex(TupFcns)
y = TupFcns[nFcn](x)
println(y)
end
end
TupVecs = (
[1, 3, 5],
[1, 4, 6, 9],
[1, 5]
)
TupFcns = (
x -> x^2,
x -> x^3,
x -> x^4
)
fcn(TupVecs) # works fine
fcn(TupFcns) # method error
Edit: Iām going to stick with vectors of functions and vectors, instead of tuples of functions and vectors.