i am doing a function in OCaml with i want to count the number of iterations in the variable n. This is the function:
let mapdoble f1 f2 l = let rec aux n f_1 f_2 l1 l2= match(n,f_1,f_2,l1,l2) with (n,_,_,[],l2) -> l2 | (n,f_1,_,h::t,l2) when n mod 2 = 0 -> aux n+1 f1 f2 t l2@[f_1 h] | (n,_,f_2,h::t,l2) when n mod 2 = 1 -> aux n+1 f1 f2 t l2@[f_2 h] in aux 0 f1 f2 l [];; When i compile it i have this error, i don't know what it is:
Error: This expression has type 'a -> 'b -> 'c list -> 'd -> 'd but an expression was expected of type int
n+1.n+1. You also have to match all cases, the compiler should warn you about that too with an example.