# Fun One Liners

**URL:** <https://discourse.julialang.org/t/fun-one-liners/28352>\
**Category:** General Usage\
**Created:** [September 3, 2019, 11:13pm UTC](https://discourse.julialang.org/t/fun-one-liners/28352 "2019-09-03T23:13:18Z")\
**Posts on this page:** 1\
**Showing post:** 77

<div class="post-metadata">

**Author:** ![MatFi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/matfi/32/10002_2.png) [@MatFi](https://discourse.julialang.org/u/MatFi)\
**Post date:** [September 19, 2019, 2:23pm UTC](https://discourse.julialang.org/t/fun-one-liners/28352/77 "2019-09-19T14:23:53Z")

</div>

> [@fredrikekre](#):
>
> `indexin` :

Ok… cool, but is there is also a method returning the indexes of values close to the given ones like :

```julia
b= [-1, 0, 1.2, 2.1, 3.5, 4.87, 5.1, 6, 7, 8]
a = [1, 2, 6, 3]
julia> indexnear(a, b)
4-element Array{Union{Nothing, Int64},1}:
 3
 4
 8
 5

```

here i can simply use `(m-> findfirst(x -> x >= m ,b)).(a)`  
how ever this solution is far from being perfect

**EDIT: Find indexes of elements in array** `b` **close to those in array** `a`  
With the help of this [thread](https://discourse.julialang.org/t/findnearest-function/4143)  
we can do:

`(m-> findmin(abs.(a.-m))[2]).(b)`

---

_[View the full topic](https://discourse.julialang.org/t/fun-one-liners/28352)._
