]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/mathql_interpreter/diff.ml
Merge of the new_mathql branch with the main branch:
[helm.git] / helm / ocaml / mathql_interpreter / diff.ml
index e2eea1bc1e8025f70f75d6a5bc409d99f1c14dea..b4e09196ee5c42e097cbc2c250f2db317d0f491b 100644 (file)
@@ -24,8 +24,8 @@
  *)
 
 (*
- * implementazione del comando DIFF
- *)
+ * vecchia implementazione del comando DIFF
 
 exception NotCompatible;;
 
@@ -45,9 +45,7 @@ let rec intersect_attributes (attr1, attr2) =
   | _, _ -> raise NotCompatible  (* same keys, different values *)
 ;;
 
-(*
- * implementazione del comando DIFF
- *)
 let rec diff_ex l1 l2 =
  let module S = Mathql_semantics in
   match (l1, l2) with
@@ -67,11 +65,27 @@ let rec diff_ex l1 l2 =
         NotCompatible ->
          {S.uri = uri1 ; S.attributes = attributes1 ; S.extra = ""}::(diff_ex tl1 tl2)
 ;;
+*)
+
+(*
+ * implementazione del comando DIFF
+ *)
+let rec diff_ex rs1 rs2 =
+  match (rs1, rs2) with
+     [],_ -> []
+   | l,[] -> l
+   | (uri1,l)::tl1,(uri2,_)::_ when uri1 < uri2 -> (uri1,l)::(diff_ex tl1 rs2)
+   | (uri1,_)::_,(uri2,_)::tl2 when uri2 < uri1 -> (diff_ex rs1 tl2)
+   | (uri1,_)::tl1, (uri2,_)::tl2 -> (diff_ex tl1 tl2)
+;;
+
+
+
 
 let diff_ex l1 l2 =
- let before = Unix.time () in
+ let before = Sys.time () in
  let res = diff_ex l1 l2 in
- let after = Unix.time () in
+ let after = Sys.time () in
   let ll1 = string_of_int (List.length l1) in
   let ll2 = string_of_int (List.length l2) in
   let diff = string_of_float (after -. before) in