let rec mapl f l = match l with | [] -> [] | a :: l1 -> let a' = f a and l1' = mapl f l1 in if l1 == l1' && eq a' a then l else a' :: l1'