Find function in Julai 1.7 -- still supported?

Hello,
I would like to find the element of a vectos above a certain threshold. I am trying with:

a = [ 1 2 3 4 3 5 3 6 7 8 9 3 ]
find( x->(x == 3), a)
find(a .== 3

but

julia> find( x->(x == 3), a)
ERROR: UndefVarError: find not defined
Stacktrace:
 [1] top-level scope
   @ none:1
julia> find(a .== 3)
ERROR: UndefVarError: find not defined
Stacktrace:
 [1] top-level scope
   @ none:1

julia> findall( x->(x == 3), a)
4-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 3)
 CartesianIndex(1, 5)
 CartesianIndex(1, 7)
 CartesianIndex(1, 12)

julia> findall(a .== 3)
4-element Vector{CartesianIndex{2}}:
 CartesianIndex(1, 3)
 CartesianIndex(1, 5)
 CartesianIndex(1, 7)
 CartesianIndex(1, 12)

How do I get the first true element?

Hello! Try findfirst() function:

findfirst(predicate::Function, A)

1 Like

or findall or type find in the repl and press tab to get more suggestions.

3 Likes