# How to return the index of element in Array in Integer not CartesianIndex?

**URL:** <https://discourse.julialang.org/t/how-to-return-the-index-of-element-in-array-in-integer-not-cartesianindex/67728>\
**Category:** General Usage\
**Tags:** question\
**Created:** [September 6, 2021, 2:34am UTC](https://discourse.julialang.org/t/how-to-return-the-index-of-element-in-array-in-integer-not-cartesianindex/67728 "2021-09-06T02:34:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amro](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Amro](https://discourse.julialang.org/u/Amro)\
**Post date:** [September 6, 2021, 2:34am UTC](https://discourse.julialang.org/t/how-to-return-the-index-of-element-in-array-in-integer-not-cartesianindex/67728/1 "2021-09-06T02:34:56Z")

</div>

I have the following array (here is vector), and I want to return the index of “8” element, which should be 4 as integer not CartesianIndex. Any solution?

```julia
julia> s=[5 6 7 8]
1×4 Matrix{Int64}:
 5 6 7 8

julia> findall(isequal(8), s)
1-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 4)

```

---

<div class="post-metadata">

**Author:** ![Wen-Wei\_Tseng](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wen-wei_tseng/32/28839_2.png) [@Wen-Wei\_Tseng](https://discourse.julialang.org/u/Wen-Wei_Tseng)\
**Post date:** [September 6, 2021, 2:50am UTC](https://discourse.julialang.org/t/how-to-return-the-index-of-element-in-array-in-integer-not-cartesianindex/67728/2 "2021-09-06T02:50:10Z")

</div>

It looked like [this](https://discourse.julialang.org/t/how-to-convert-cartesianindex-n-values-to-int64/15074/6).

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [September 6, 2021, 5:08am UTC](https://discourse.julialang.org/t/how-to-return-the-index-of-element-in-array-in-integer-not-cartesianindex/67728/3 "2021-09-06T05:08:23Z")

</div>

In general, you can use `LinearIndices` to map from cartesian to linear indexing:

```julia
s = [5 6 7 8]
inds = findall(isequal(8), s)
li = LinearIndices(s)
li[inds]

```

> [@Amro](#):
>
> I have the following array (here is vector)

Note that the `find` family of functions return linear indices for input vectors:

```julia
v = [5, 6, 7, 8]
findall(isequal(8), v)

```
