X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fmathql_interpreter%2Fdiff.ml;h=5cba32345fcaa7702e9e75e8afd0a18701d605c4;hb=89262281b6e83bd2321150f81f1a0583645eb0c8;hp=b32468e40721e5b4637025f29b7636801c53bd9d;hpb=f870fdd883e3380f77f260709d4cb76e9d5def2b;p=helm.git diff --git a/helm/ocaml/mathql_interpreter/diff.ml b/helm/ocaml/mathql_interpreter/diff.ml index b32468e40..5cba32345 100644 --- a/helm/ocaml/mathql_interpreter/diff.ml +++ b/helm/ocaml/mathql_interpreter/diff.ml @@ -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,18 +65,34 @@ 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 - prerr_endline + print_endline ("DIFF(" ^ ll1 ^ ", " ^ ll2 ^ ") = " ^ string_of_int (List.length res) ^ ": " ^ diff ^ "s") ; - flush stderr ; + flush stdout ; res ;; - +*)