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

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:

``````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?

1 Like
``````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
``````

1 Like

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

``````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> collect((2,8))
2-element Vector{Int64}:
2
8
``````
2 Likes