# A unified type of \`Tuple\` and \`Vector\`

**URL:** https://discourse.julialang.org/t/a-unified-type-of-tuple-and-vector/22552
**Category:** General Usage
**Tags:** question, type
**Created:** [March 30, 2019, 10:05pm UTC](https://discourse.julialang.org/t/a-unified-type-of-tuple-and-vector/22552 "2019-03-30T22:05:59Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)
#### Post date: [March 30, 2019, 10:05pm UTC](https://discourse.julialang.org/t/a-unified-type-of-tuple-and-vector/22552/1 "2019-03-30T22:05:59Z")

</div>

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

```julia
const TupOrVec = Union{Tuple, Vector}

```

Why does not Julia provide such a type for us?

---

<div class="post-metadata">

### Author: ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)
#### Post date: [March 30, 2019, 10:18pm UTC](https://discourse.julialang.org/t/a-unified-type-of-tuple-and-vector/22552/2 "2019-03-30T22:18:04Z")

</div>

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 `Set`s? etc. etc.

---

<div class="post-metadata">

### Author: ![singularitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/singularitti/32/17678_2.png) [@singularitti](https://discourse.julialang.org/u/singularitti)
#### Post date: [March 30, 2019, 10:19pm UTC](https://discourse.julialang.org/t/a-unified-type-of-tuple-and-vector/22552/3 "2019-03-30T22:19:41Z")

</div>

That’s a good point. Thank you.

---

<div class="post-metadata">

### Author: ![frankwswang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/frankwswang/32/18561_2.png) [@frankwswang](https://discourse.julialang.org/u/frankwswang)
#### Post date: [September 21, 2022, 3:16am UTC](https://discourse.julialang.org/t/a-unified-type-of-tuple-and-vector/22552/4 "2022-09-21T03:16:03Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)
#### Post date: [September 21, 2022, 9:12am UTC](https://discourse.julialang.org/t/a-unified-type-of-tuple-and-vector/22552/5 "2022-09-21T09:12:30Z")

</div>

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.
