# How exactly "in" and "not in" works in tuples?

**URL:** <https://discourse.julialang.org/t/how-exactly-in-and-not-in-works-in-tuples/96305>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 19, 2023, 12:22pm UTC](https://discourse.julialang.org/t/how-exactly-in-and-not-in-works-in-tuples/96305 "2023-03-19T12:22:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Optimization](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/optimization/32/32462_2.png) [@Optimization](https://discourse.julialang.org/u/Optimization)\
**Post date:** [March 19, 2023, 12:22pm UTC](https://discourse.julialang.org/t/how-exactly-in-and-not-in-works-in-tuples/96305/1 "2023-03-19T12:22:26Z")

</div>

Hi all,

I’m trying to check some belonging conditions over some tuples. One set of tuples are numeric like `(2,8)` and the others are combined with text `(2,8,'e','f')`.

I want to check for every numeric pair their existance in the 4-mixed tuples. So, I did this:

```julia
reduce(union, (2,8))
2-element Vector{Int64}:
  2
 8

reduce(union, (2,8, "e", "f"))
4-element Vector{Any}:
 2
 8
  'e': ASCII/Unicode U+0065 (category Ll: Letter, lowercase)
  'f': ASCII/Unicode U+0066 (category Ll: Letter, lowercase)

reduce(union,(2,8)) in reduce(union, (2,8, "e", "f"))
false

```

Then, why `reduce(union,(2,8)) in reduce(union, (2,8, "e", "f"))` return false?

---

<div class="post-metadata">

**Author:** ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)\
**Post date:** [March 19, 2023, 12:38pm UTC](https://discourse.julialang.org/t/how-exactly-in-and-not-in-works-in-tuples/96305/2 "2023-03-19T12:38:51Z")

</div>

```julia
help?> in
...
  in(item, collection) -> Bool
  ∈(item, collection) -> Bool

  Determine whether an item is in the given collection, in the sense 
  that it is == to one of the values generated by iterating over the 
  collection.
....

julia> in(reduce(union,(2,8)), reduce(union, (2,8, "e", "f")))
false

julia> map(in,reduce(union,(2,8)), reduce(union, (2,8, "e", "f")))
2-element Vector{Bool}:
 1
 1

```

Does this answer your question?

---

<div class="post-metadata">

**Author:** ![yha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yha/32/3502_2.png) [@yha](https://discourse.julialang.org/u/yha)\
**Post date:** [March 19, 2023, 4:38pm UTC](https://discourse.julialang.org/t/how-exactly-in-and-not-in-works-in-tuples/96305/3 "2023-03-19T16:38:28Z")

</div>

You might be looking for `issubset` (can also be written as the binary operator `⊆` (`\subseteq`)).

```julia
julia> issubset((2,8), (2,8,"e","f"))
true

julia> (2,8) ⊆ (2,3,4)
false

```

If you still also need to convert your tuples to vectors, you can use `collect` – no need to do `reduce(union,...)`.

```julia
julia> collect((2,8))
2-element Vector{Int64}:
 2
 8

```
