let rec add_force cube v trie = match trie with | Empty -> List.fold_right (fun a t -> Node [a,t]) cube (Full v) | Full _ -> trie | Node l -> match cube with | [] -> Full v | atom::cube -> Node (add_force_to_list atom cube v l) and add_force_to_list atom cube v l = match l with | [] -> [atom, add_force cube v Empty] | (atom',t')::n -> let cmp = Atom.compare atom atom' in if cmp > 0 then (atom',t')::(add_force_to_list atom cube v n) else (atom, add_force cube v Empty)::l