let findi t ~f = let rec loop i t = match t with | [] -> None | x :: l -> if f i x then Some (i, x) else loop (i + 1) l in loop 0 t