let merge canonicals elements n m =
let cn,canonicals = rm_assoc n canonicals in
let cm,canonicals = rm_assoc m canonicals in
- let ln,elements = rm_assoc cn elements in
- let lm,elements = rm_assoc cm elements in
- let canonicals =
- (n,cm)::(m,cm)::List.map
- (fun ((x,xc) as p) ->
- if xc = cn then (x,cm) else p) canonicals
- in
- let elements = (cm,ln@lm)::elements
- in
- canonicals,elements
+ if cn=cm then (n,cm)::(m,cm)::canonicals, elements
+ else
+ let ln,elements = rm_assoc cn elements in
+ let lm,elements = rm_assoc cm elements in
+ let canonicals =
+ (n,cm)::(m,cm)::List.map
+ (fun ((x,xc) as p) ->
+ if xc = cn then (x,cm) else p) canonicals
+ in
+ let elements = (cm,ln@lm)::elements
+ in
+ canonicals,elements
;;
(* f x gives the direct dependencies of x;