# Where is 'findprev' located?

**URL:** <https://discourse.julialang.org/t/where-is-findprev-located/107407>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 11, 2023, 2:53am UTC](https://discourse.julialang.org/t/where-is-findprev-located/107407 "2023-12-11T02:53:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Post date:** [December 11, 2023, 2:53am UTC](https://discourse.julialang.org/t/where-is-findprev-located/107407/1 "2023-12-11T02:53:03Z")

</div>

I guess it is from the Base module.

How to find it out?

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [December 11, 2023, 2:59am UTC](https://discourse.julialang.org/t/where-is-findprev-located/107407/2 "2023-12-11T02:59:00Z")

</div>

You can use the command `methods(findprev)` to see the files involved. There are multiple methods for this function in several files, depending on the input type.

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [December 11, 2023, 7:58am UTC](https://discourse.julialang.org/t/where-is-findprev-located/107407/3 "2023-12-11T07:58:10Z")

</div>

If you are unsure which of the methods from @steffenPL s call is actually called, you can use `@which` and it tells you which version it dispatches on

```julia
julia> @which findprev([false, false, true, false],3)
findprev(A, start)
     @ Base array.jl:2173

```

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [December 11, 2023, 10:42am UTC](https://discourse.julialang.org/t/where-is-findprev-located/107407/4 "2023-12-11T10:42:05Z")

</div>

And to slightly expand on @kellertuer’s answer: You can also use `@edit` to directly open the code definition in your favourite editor.

```julia-repl
julia> @edit findprev([false, false, true, false],3)
#= editor opens =#

```

---

<div class="post-metadata">

**Author:** ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Post date:** [December 13, 2023, 1:16pm UTC](https://discourse.julialang.org/t/where-is-findprev-located/107407/5 "2023-12-13T13:16:20Z")

</div>

unfortunately, it seems that these work only for some inbuilt functions of Julia. I am using a package written by some people, and neither @which nor @edit work for the functions in the package. I got

```julia
ERROR: expression is not a function call, or is too complex for @edit to analyze; break it down to simpler parts if possible. In some cases, you may want to use Meta.@lower.
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:35
 [2] top-level scope
   @ REPL[8]:1

```

---

<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:** [December 13, 2023, 1:17pm UTC](https://discourse.julialang.org/t/where-is-findprev-located/107407/6 "2023-12-13T13:17:52Z")

</div>

@jiang_ming_zhang can you give a complete example that we can try?

---

<div class="post-metadata">

**Author:** ![kellertuer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kellertuer/32/220707_2.png) [@kellertuer](https://discourse.julialang.org/u/kellertuer)\
**Post date:** [December 13, 2023, 1:49pm UTC](https://discourse.julialang.org/t/where-is-findprev-located/107407/7 "2023-12-13T13:49:24Z")

</div>

As the error message states, I would also think that maybe the arguments of your function call are a bit too complex (maybe with nested function calls?)

Note that the whole `@which` command works for arbitrary packages and functions since all packages provide their code, so e.g.

```julia-repl
julia> using JuliaFormatter
julia> @which format(".")
format(path::AbstractString; options...)
     @ JuliaFormatter ~/.julia/packages/JuliaFormatter/ddD3y/src/JuliaFormatter.jl:425

```

or also for packages in development mode

```julia-repl
julia> using Manifolds
julia> @which Sphere(3)
Sphere(n::Int64)
     @ Manifolds ~/path-to-your-local-repo/src/manifolds/Sphere.jl:55

```

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [December 13, 2023, 2:01pm UTC](https://discourse.julialang.org/t/where-is-findprev-located/107407/8 "2023-12-13T14:01:49Z")

</div>

Or indeed for functions that the user just defined in a current session:

```julia
julia> f(x::Int) = 1
f (generic function with 1 method)

julia> f(x::Float64) = 1.0
f (generic function with 2 methods)

julia> @which f(1)
f(x::Int64)
     @ Main REPL[17]:1

julia> @which f(1.0)
f(x::Float64)
     @ Main REPL[18]:1

```
