# Questions about vector

**URL:** https://discourse.julialang.org/t/questions-about-vector/88153
**Category:** New to Julia
**Tags:** question, arrays
**Created:** [October 3, 2022, 11:49am UTC](https://discourse.julialang.org/t/questions-about-vector/88153 "2022-10-03T11:49:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![zhangchunyong](https://avatars.discourse-cdn.com/v4/letter/z/d9b06d/32.png) [@zhangchunyong](https://discourse.julialang.org/u/zhangchunyong)
#### Post date: [October 3, 2022, 11:49am UTC](https://discourse.julialang.org/t/questions-about-vector/88153/1 "2022-10-03T11:49:36Z")

</div>

```julia
a=[[1],[1,2],[2,1],[2,5],[111,3],[4,1]]
6-element Vector{Vector{Int64}}:
 [1]
 [1, 2]
 [2, 1]
 [2, 5]
 [111, 3]
 [4, 1]

```

I want to get the index which of them contain a element named 1,but 111 is not allowed.I want to return [1,2,3,6] .If the sub-vector contains real 1 ,I will return the index. What should I do ? Thanks very much.  
findall?

---

<div class="post-metadata">

### Author: ![JorizovdZ](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jorizovdz/32/43064_2.png) [@JorizovdZ](https://discourse.julialang.org/u/JorizovdZ)
#### Post date: [October 3, 2022, 12:00pm UTC](https://discourse.julialang.org/t/questions-about-vector/88153/2 "2022-10-03T12:00:01Z")

</div>

I do not know how you want to approach this as `a` is a vector of vectors.

Though something like this does work:

```julia
findall.(x -> x == 1, a)

```

---

<div class="post-metadata">

### Author: ![zhangchunyong](https://avatars.discourse-cdn.com/v4/letter/z/d9b06d/32.png) [@zhangchunyong](https://discourse.julialang.org/u/zhangchunyong)
#### Post date: [October 3, 2022, 12:01pm UTC](https://discourse.julialang.org/t/questions-about-vector/88153/3 "2022-10-03T12:01:59Z")

</div>

> [@JorizovdZ](#):
>
> `findall.(x -> x == 1, a)`

```julia
findall.(x -> x == 1, a)
6-element Vector{Vector{Int64}}:
 [1]
 [1]
 [2]
 [1]
 []
 [2]

```

Sorry, It cannot return the index. like [1,2,3,6]

---

<div class="post-metadata">

### Author: ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)
#### Post date: [October 3, 2022, 12:02pm UTC](https://discourse.julialang.org/t/questions-about-vector/88153/4 "2022-10-03T12:02:50Z")

</div>

```julia
julia> findall(x -> 1 in x, a)
4-element Vector{Int64}:
 1
 2
 3
 6

```

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [October 3, 2022, 12:02pm UTC](https://discourse.julialang.org/t/questions-about-vector/88153/5 "2022-10-03T12:02:50Z")

</div>

> [@zhangchunyong](#):
>
> `a=[[1],[1,2],[2,1],[2,5],[111,3],[4,1]]`

```julia
julia> findall(1 in v for v in a)
4-element Vector{Int64}:
 1
 2
 3
 6

```

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [October 4, 2022, 7:15pm UTC](https://discourse.julialang.org/t/questions-about-vector/88153/6 "2022-10-04T19:15:41Z")

</div>

An alternative:

```julia
LinearIndices(a)[in.(1, a)]

```
