A unified type of `Tuple` and `Vector`

Sometimes I want my functions to work with both Tuples and Vectors. Those functions are pure and are iterating through each element of the Tuples and Vectors. Is there a unified type representing Tuples and Vectors? Or I have to define

const TupOrVec = Union{Tuple, Vector}

Why does not Julia provide such a type for us?

Because what if a package implements some iterable 1-D container that you also want to be able to accept as input? Or what about an Array{T, 3} where T which is 3-dimensional but also iterable with eachindex? What about Sets? etc. etc.

1 Like

That’s a good point. Thank you.

1 Like