A unified type of `Tuple` and `Vector`

question
type
#1

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?

#2

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
#3

That’s a good point. Thank you.

1 Like