- let rec helper (predecessor : 'a) n lst =
- match lst with
- | [] -> failwith "not found"
- | x :: xs when test x -> (if n = 1
- then (predecessor, x, match xs with [] -> default | y::ys -> y)
- else helper x (n - 1) xs
- )
- | x :: xs -> helper x n xs
- in helper default n lst;;
+ let rec helper (predecessor : 'a) n lst =
+ match lst with
+ | [] -> failwith "not found"
+ | x :: xs when test x -> (if n = 1
+ then (predecessor, x, match xs with [] -> default | y::ys -> y)
+ else helper x (n - 1) xs
+ )
+ | x :: xs -> helper x n xs
+ in helper default n lst;;