Function that takes a tuple of (unknown number of) vectors of given type

I have a function (called form within an outer function) that I want to take a tuple of vectors of n integers. n is fixed for a given run of the outer function. How would I set this up?

function inner_func1(n ::Int64)
    return Tuple([[1,2,3] for i in 1:n])
end
function inner_func2(y ::Tuple{Vector{Int64}})
    return y[end]
end
function main_func(n)
    y = inner_func1(n)
    z = inner_func2(y)
end
main_func(3)

gives

ERROR: MethodError: no method matching inner_func2(::Tuple{Vector{Int64}, Vector{Int64}, Vector{Int64}})
Closest candidates are:
  inner_func2(::Tuple{Vector{Int64}}) at REPL[126]:1
Stacktrace:
 [1] main_func(n::Int64)
   @ Main .\REPL[127]:3
 [2] top-level scope
   @ REPL[128]:1```

Tuple{Vector{Int64}} only allows for 1 entry in the tuple, you want Tuple{Vararg{Vector{Int64}}}.

But you probably shouldn’t be doing this many type annotations anyways. It won’t improve performance.

1 Like

Thank you.