Good day.
How to find index of the element in array? No word about it in docs. Only way I found is:
let arr = [|1; 4; 5; 10|]
let elem = 5
let i = Array.findIndex (fun e -> e = elem) arr
You can create a shortcut function yourself if you use it frequently:
let findIndex arr elem = arr |> Array.findIndex ((=) elem)
...
let i = findIndex arr elem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.