# Use of 'in' or function in array

**URL:** <https://discourse.julialang.org/t/use-of-in-or-function-in-array/45636>\
**Category:** General Usage\
**Created:** [August 27, 2020, 5:23pm UTC](https://discourse.julialang.org/t/use-of-in-or-function-in-array/45636 "2020-08-27T17:23:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jobdiogenes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jobdiogenes/32/30544_2.png) [@jobdiogenes](https://discourse.julialang.org/u/jobdiogenes)\
**Post date:** [August 27, 2020, 5:23pm UTC](https://discourse.julialang.org/t/use-of-in-or-function-in-array/45636/1 "2020-08-27T17:23:34Z")

</div>

Example array:  
C = [1 2 3 5;4 5 6 8;7 8 9 0; 3 6 9 12]  
4×4 Array{Int64,2}:  
1 2 3 5  
4 5 6 8  
7 8 9 0  
3 6 9 1

I could strip out cols, or rows by

```julia
C[1:end .!=2,1:end .!=3]
3×3 Array{Int64,2}:
 1 2 5
 7 8 0
 3 6 1

```

But, I would expect to use **in** like:

```julia
C[1:end .in([2 3]),1:end .in([1 3])]

```

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [August 27, 2020, 5:29pm UTC](https://discourse.julialang.org/t/use-of-in-or-function-in-array/45636/2 "2020-08-27T17:29:05Z")

</div>

You can do

```julia
C[in.(1:end, Ref([2, 3])), in.(1:end, Ref([1, 3]))]

```

, or even better, if `[2, 3]` and `[1, 3]` are large arrays:

```julia
C[in.(1:end, Ref(Set([2, 3]))), in.(1:end, Ref(Set([1, 3])))]

```

---

<div class="post-metadata">

**Author:** ![jobdiogenes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jobdiogenes/32/30544_2.png) [@jobdiogenes](https://discourse.julialang.org/u/jobdiogenes)\
**Post date:** [August 27, 2020, 6:00pm UTC](https://discourse.julialang.org/t/use-of-in-or-function-in-array/45636/3 "2020-08-27T18:00:46Z")

</div>

> [@simeonschaub](#):
>
> `C[in.(1:end, Ref([2, 3])), in.(1:end, Ref([1, 3]))]`

@simeonschaub Thanks very much.  
Your suggestion works,

I’m was looking a way to strip out row or cols which has sum of rows or cols in some condition.  
then I use eachrow and eachcol to get these rows/cols conditions.  
With your suggestions I could create a very nice function.  
After I learn more about Julia, I will try to make a generic function to strip out rows/cols for arrays.
