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