# Scalar contained by vector of StaticArrays

**URL:** <https://discourse.julialang.org/t/scalar-contained-by-vector-of-staticarrays/55549>\
**Category:** New to Julia\
**Created:** [February 18, 2021, 3:46pm UTC](https://discourse.julialang.org/t/scalar-contained-by-vector-of-staticarrays/55549 "2021-02-18T15:46:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ribeiro](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@Ribeiro](https://discourse.julialang.org/u/Ribeiro)\
**Post date:** [February 18, 2021, 3:46pm UTC](https://discourse.julialang.org/t/scalar-contained-by-vector-of-staticarrays/55549/1 "2021-02-18T15:46:51Z")

</div>

Hi!  
I want to check if an integer is contained by a vector of StaticArrays. Here’s an example (with regular arrays, but it’s the same issue).

```julia
a = [[1,2], [3,4]]
1 in a # false

```

I guess I could write a for loop, but that’s not very elegant.  
Notes:

- The number I’m looking for will always be in the first “column” (i.e., first position of a subarray).
- If the number is in `a`, I will need to find it’s position, something like this: `findfirst(x->x==1,a)`, which doesn’t work in this case either.

Thanks a lot!  
PS: this is a silly question, but a difficult one to Google. The word “in” is a bit too common.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 18, 2021, 3:49pm UTC](https://discourse.julialang.org/t/scalar-contained-by-vector-of-staticarrays/55549/2 "2021-02-18T15:49:02Z")

</div>

```julia
julia> any(∋(1), a)
true

julia> findfirst(∋(1), a)
1

```

note: this only handles one level of nest-ness

---

<div class="post-metadata">

**Author:** ![Ribeiro](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@Ribeiro](https://discourse.julialang.org/u/Ribeiro)\
**Post date:** [February 18, 2021, 4:14pm UTC](https://discourse.julialang.org/t/scalar-contained-by-vector-of-staticarrays/55549/3 "2021-02-18T16:14:29Z")

</div>

> [@jling](#):
>
> `any(∋(1), a)`

That doesn’t seem to work for me.

```julia
julia> any(∋(1), a)
ERROR: MethodError: no method matching ∋(::Int64)
Closest candidates are:
  ∋(::Any, ::Any) at operators.jl:1069
Stacktrace:
 [1] top-level scope at REPL[14]:1

```

I’m also having some trouble with the `∋` character. Launching Julia in Windows it looks like a square with a question mark in the middle, while in Linux and in VS Code it does appear. Does this function have another name?  
I’m using Julia Version 1.5.3.  
Thanks!

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [February 18, 2021, 4:16pm UTC](https://discourse.julialang.org/t/scalar-contained-by-vector-of-staticarrays/55549/4 "2021-02-18T16:16:48Z")

</div>

yeah got added “recentlly”  
[https://github.com/JuliaLang/julia/pull/38475](https://github.com/JuliaLang/julia/pull/38475)

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [February 18, 2021, 4:25pm UTC](https://discourse.julialang.org/t/scalar-contained-by-vector-of-staticarrays/55549/5 "2021-02-18T16:25:44Z")

</div>

In the meantime you can use `any(v -> 1 ∈ v, a)`

---

<div class="post-metadata">

**Author:** ![Ribeiro](https://avatars.discourse-cdn.com/v4/letter/r/d9b06d/32.png) [@Ribeiro](https://discourse.julialang.org/u/Ribeiro)\
**Post date:** [February 18, 2021, 4:33pm UTC](https://discourse.julialang.org/t/scalar-contained-by-vector-of-staticarrays/55549/6 "2021-02-18T16:33:53Z")

</div>

Thank you both!  
For now:

```julia
any(v -> 1 ∈ v, a)
findfirst(v -> 1 ∈ v, a)

```

Works for me!
