+++ /dev/null
-(* Copyright (C) 2000, HELM Team.
- *
- * This file is part of HELM, an Hypertextual, Electronic
- * Library of Mathematics, developed at the Computer Science
- * Department, University of Bologna, Italy.
- *
- * HELM is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * HELM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HELM; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- * MA 02111-1307, USA.
- *
- * For details, see the HELM World-Wide-Web page,
- * http://cs.unibo.it/helm/.
- *)
-
-
-(* Catenates two lists preserving order and getting rid of duplicates *)
-let rec append (l1,l2) =
- match l1,l2 with
- [],_ -> l2
- | _,[] -> l1
- | s1::tl1, s2::_ when s1 < s2 -> s1::append (tl1,l2)
- | s1::_, s2::tl2 when s2 < s1 -> s2::append (l1,tl2)
- | s1::tl1, s2::tl2 -> s1::append (tl1,tl2)
-
-;;
-
-
-(* Sums two attribute groups preserving order *)
-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))
-
-;;
-
-(* Product between an attribute set and a group of attributes *)
-let rec sub_prod (aset, gr) = (*prende un aset e un gr, fa la somma tra tutti i gruppi di aset e gr*)
- match aset with
- [] -> []
- | gr1::tl1 -> sum_groups (gr1, gr)::(sub_prod(tl1, gr))
-;;
-
-
-(* Cartesian product between two attribute sets*)
-let rec prod (as1, as2) =
- match as1, as2 with
- [],_ -> []
- | _,[] -> []
- | 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 *)
-let rec intersect_ex rs1 rs2 =
- match (rs1, rs2) with
- [],_
- | _,[] -> []
- | (uri1,_)::tl1, (uri2,_)::_ when uri1 < uri2 -> intersect_ex tl1 rs2
- | (uri1,_)::_, (uri2,_)::tl2 when uri2 < uri1 -> intersect_ex rs1 tl2
- | (uri1,as1)::tl1, (uri2,as2)::tl2 -> (uri1, prod(as1,as2))::intersect_ex tl1 tl2
-;;