用法一
findlast(A)返回 A 中最後一個 true 值的索引或鍵。如果 A 中沒有 true 值,則返回 nothing 。
索引或鍵的類型與   和 keys(A)   返回的類型相同。pairs(A) 
另請參閱: 、findfirst  、findprev  。findall 
例子
julia> A = [true, false, true, false]
4-element Vector{Bool}:
 1
 0
 1
 0
julia> findlast(A)
3
julia> A = falses(2,2);
julia> findlast(A) # returns nothing, but not printed in the REPL
julia> A = [true false; true false]
2×2 Matrix{Bool}:
 1  0
 1  0
julia> findlast(A)
CartesianIndex(2, 1)用法二
findlast(predicate::Function, A)返回 A 的最後一個元素的索引或鍵 predicate 為其返回 true 。如果沒有這樣的元素,則返回 nothing。
索引或鍵的類型與   和 keys(A)   返回的類型相同。pairs(A) 
例子
julia> A = [1, 2, 3, 4]
4-element Vector{Int64}:
 1
 2
 3
 4
julia> findlast(isodd, A)
3
julia> findlast(x -> x > 5, A) # returns nothing, but not printed in the REPL
julia> A = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4
julia> findlast(isodd, A)
CartesianIndex(2, 1)用法三
findlast(pattern::AbstractString, string::AbstractString)在 string 中查找最後一次出現的 pattern。等效於   。findprev(pattern, string, lastindex(string)) 
例子
julia> findlast("o", "Hello to the world")
15:15
julia> findfirst("Julia", "JuliaLang")
1:5用法四
findlast(ch::AbstractChar, string::AbstractString)在 string 中查找字符 ch 的最後一次出現。
Julia 1.3
此方法至少需要 Julia 1.3。
例子
julia> findlast('p', "happy")
4
julia> findlast('z', "happy") === nothing
true相關用法
- Julia findlast()用法及代碼示例
- Julia findfirst方法用法及代碼示例
- Julia findall方法用法及代碼示例
- Julia findmax()用法及代碼示例
- Julia findnext方法用法及代碼示例
- Julia findprev方法用法及代碼示例
- Julia findmin()用法及代碼示例
- Julia findfirst()用法及代碼示例
- Julia findmax用法及代碼示例
- Julia findprev()用法及代碼示例
- Julia findmin用法及代碼示例
- Julia findnext()用法及代碼示例
- Julia finalizer用法及代碼示例
- Julia fill!用法及代碼示例
- Julia first方法用法及代碼示例
- Julia firstindex用法及代碼示例
- Julia fieldnames用法及代碼示例
- Julia filter!用法及代碼示例
- Julia fill用法及代碼示例
- Julia fieldname用法及代碼示例
- Julia fieldtypes用法及代碼示例
- Julia first用法及代碼示例
- Julia filter用法及代碼示例
- Julia first()用法及代碼示例
- Julia float方法用法及代碼示例
注:本文由純淨天空篩選整理自julialang.org 大神的英文原創作品 Base.findlast — Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
