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

Sorry I might be a bit late, but I don’t see why this contradicts the idea of defining a union type of Vector and Tuple (or, more precisely, NTuple) ? Thanks!

I think the question was why such a Union is not part of the Julia base.

Sure everyone can define it for themself the Union of the collections they need, but for begin part of base it is to specific as there are many different use cases which would need other unions instead.