(* valuta una MathQL.val_exp e ritorna un MathQL.value *)
and exec_val_exp c = function
- | MathQL.Const x -> List.sort compare x
+ | MathQL.Const x -> let ol = List.sort compare x in
+ let rec edup = function
+ [] ->
+ | s::tl -> if s = (List.tl tl) then edup tl
+ else s::(edup tl)
+ in
+ edup ol
| MathQL.Record (rvar, vvar) -> List.assoc vvar (List.assoc rvar c.groups)
| MathQL.VVar s -> List.assoc s c.vvars
--- /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://www.cs.unibo.it/helm/.
+ *)
+
+
+open Dbconn;;
+open Utility;;
+(*
+ * implementazione del comando Relation
+ *)
+
+
+let get_prop_id propl =
+ let prop = List.hd propl in
+ if prop="refObj" then "F"
+ else if prop="backPointer" then "B"
+ else assert false
+;;
+
+
+
+let relation_ex rop path rset attl =
+ if path = [] then []
+ else
+ let usek = get_prop_id path in
+
+let vvar = if attl = [] then "position"
+ else List.hd attl
+in
+(*let (uril,atts) = List.split rset in*)
+let _ = print_string ("RELATION "^usek)
+and t = Unix.time () in
+let result =
+ let c = pgc () in
+ List.sort
+compare
+(List.fold_left (fun acc (uri,l) ->
+ let tv = pgresult_to_string (c#exec ("select id from registry where uri='" ^ uri ^ "'"))
+ in
+ let qq = "select uri, context from t" ^ tv ^ " where prop_id='" ^ usek ^ "' order by uri asc"
+ in
+ let res = c#exec qq in
+ (List.map
+ (function [uri;context] -> (uri,[[(vvar,[context])]])
+ | _ -> assert false )
+ res#get_list) @ acc
+ )
+ [] rset
+)
+(*Come faccio a togliere i duplicati????*)
+
+
+in
+print_string (" = " ^ string_of_int (List.length result) ^ ": ") ;
+print_endline (string_of_float (Unix.time () -. t) ^ "s") ;
+flush stdout ;
+ result
+;;
+
--- /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/.
+ *)
+
+val relation_ex :
+ MathQL.refine_op -> MathQL.path -> MathQL.resource_set -> MathQL.vvar_list -> MathQL.resource_set