let rec list_assoc_remove key f = function
| [] -> raise Not_found
| (key',value) as elt :: tail ->
if key <> key'
then elt :: list_assoc_remove key f tail
else match f value with
| None -> tail
| Some a -> (key',a) :: tail