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))
(* 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 *)