I am new to programming in functional languages. I am attempting to implement the F# tryFindIndex function.
let rec tryFindIndex func list =
match list with
| [] -> None
| hd::tl -> if func hd then Some(0)
else (tryFindIndex func tl) + 1
The issue is with the last line, since adding 1 causes the return type to be 'int' instead of 'int option'. I need to track the index recursively.