From c77c9107d0a456b0276383fc4c97bb491d1c7156 Mon Sep 17 00:00:00 2001 From: natile Date: Thu, 10 Oct 2002 14:19:25 +0000 Subject: [PATCH] Intersect patched.. --- helm/ocaml/mathql_interpreter/intersect.ml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/helm/ocaml/mathql_interpreter/intersect.ml b/helm/ocaml/mathql_interpreter/intersect.ml index 6503a3942..84eb186a6 100644 --- a/helm/ocaml/mathql_interpreter/intersect.ml +++ b/helm/ocaml/mathql_interpreter/intersect.ml @@ -41,6 +41,7 @@ let rec sum_groups(gr1, gr2) = match gr1, gr2 with [],_ -> gr2 | _,[] -> gr1 + | gr1, gr2 when gr1 = gr2 -> gr1 | (key1,l1)::tl1, (key2,l2)::_ when key1 < key2 -> (key1,l1)::(sum_groups (tl1,gr2)) | (key1,l1)::_, (key2,l2)::tl2 when key2 < key1 -> (key2,l2)::(sum_groups (gr1,tl2)) | (key1,l1)::tl1, (key2,l2)::tl2 -> (key1,(append (l1,l2)))::(sum_groups (tl1,tl2)) @@ -58,9 +59,9 @@ let rec sub_prod (aset, gr) = (*prende un aset e un gr e fa la somma t (* Cartesian product between two attribute sets*) let rec prod (as1, as2) = match as1, as2 with - [],_ -> as2 - | _,[] -> as1 - | gr1::tl1, _ -> (sub_prod (as2, gr1))@(prod (tl1, as2)) (* chiamo la sub_prod con un el. as1 e as2 *) + [],_ -> [] + | _,[] -> [] + | gr1::tl1, _ -> append((sub_prod (as2, gr1)), (prod (tl1, as2))) (* chiamo la sub_prod con un el. as1 e as2 *) ;; (* Intersection between two resource sets, preserves order and gets rid of duplicates *) -- 2.39.2