struct
let get e l = try Some (assoc e l) with Not_found -> None
let getq e l = try Some (assq e l) with Not_found -> None
let mem = mem_assoc
let memq = mem_assq
let remove_assoc = remove_assoc
let remove_assq = remove_assq
let remove_and_get el list =
let rec loop acc = function
| [] -> None
| (e, v) :: t when e = el -> Some (v, (List.rev acc @ t))
| h :: t -> loop (h :: acc) t
in
loop [] list
let remove_and_getq el list =
let rec loop acc = function
| [] -> None
| (e, v) :: t when e == el -> Some (v, (List.rev acc @ t))
| h :: t -> loop (h :: acc) t
in
loop [] list
end