From 39cbf1a39c008ac738b121178a5110cafd8c6ffa Mon Sep 17 00:00:00 2001 From: Ferruccio Guidi Date: Sat, 21 Sep 2002 18:42:07 +0000 Subject: [PATCH] intersect.ml cleaned --- helm/ocaml/mathql_interpreter/intersect.ml | 41 +++++++++++++++------- 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/helm/ocaml/mathql_interpreter/intersect.ml b/helm/ocaml/mathql_interpreter/intersect.ml index 9a0f408ef..e56d1d1f3 100644 --- a/helm/ocaml/mathql_interpreter/intersect.ml +++ b/helm/ocaml/mathql_interpreter/intersect.ml @@ -65,18 +65,33 @@ let rec prod (as1, as2) = ;; (* Intersection between two resource sets, preserves order and gets rid of duplicates *) -let rec intersect_ex rs1 rs2 = - match (rs1, rs2) with - [],_ - | _,[] -> [] - | (uri1,as1)::tl1, - (uri2,as2)::_ when uri1 < uri2 -> intersect_ex tl1 rs2 - | (uri1,as1)::_, - (uri2,as2)::tl2 when uri2 < uri1 -> intersect_ex rs1 tl2 - | (uri1,as1)::tl1, - (uri2,as2)::tl2 -> (uri1, prod(as1,as2))::intersect_ex tl1 tl2 +let intersect_ex rs1 rs2 = + let rec intersect_aux rs1 rs2 = + match (rs1, rs2) with + [],_ + | _,[] -> [] + | (uri1,as1)::tl1, + (uri2,as2)::_ when uri1 < uri2 -> intersect_aux tl1 rs2 + | (uri1,as1)::_, + (uri2,as2)::tl2 when uri2 < uri1 -> intersect_aux rs1 tl2 + | (uri1,as1)::tl1, + (uri2,as2)::tl2 -> (uri1, prod(as1,as2))::intersect_aux tl1 tl2 + in + let before = Sys.time () in + let res = intersect_aux rs1 rs2 in + let after = Sys.time () in + let ll1 = string_of_int (List.length rs1) in + let ll2 = string_of_int (List.length rs2) in + let diff = string_of_float (after -. before) in + print_endline + ("INTERSECT(" ^ ll1 ^ "," ^ ll2 ^ ") = " ^ string_of_int (List.length res) ^ + ": " ^ diff ^ "s") ; + flush stdout ; + res ;; +(* + let intersect_ex l1 l2 = (* PRE-CLAUDIO (*let _ = print_string ("INTERSECT ") @@ -129,9 +144,9 @@ let intersect_ex l1 l2 = in (*let _ = print_endline (string_of_float (Unix.time () -. t)); flush stdout in*) result*) - let before = Unix.time () in + let before = Sys.time () in let res = intersect_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 @@ -141,3 +156,5 @@ let intersect_ex l1 l2 = flush stdout ; res ;; + +*) -- 2.39.2