From b6295a30e0534c8e3a06ddbcc46c8565726437b0 Mon Sep 17 00:00:00 2001 From: natile Date: Tue, 1 Oct 2002 16:26:58 +0000 Subject: [PATCH] After add relation.ml relation.mli --- helm/ocaml/mathql_interpreter/mqint.ml | 8 ++- helm/ocaml/mathql_interpreter/relation.ml | 80 ++++++++++++++++++++++ helm/ocaml/mathql_interpreter/relation.mli | 27 ++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 helm/ocaml/mathql_interpreter/relation.ml create mode 100644 helm/ocaml/mathql_interpreter/relation.mli diff --git a/helm/ocaml/mathql_interpreter/mqint.ml b/helm/ocaml/mathql_interpreter/mqint.ml index 95d3c8f2e..688158fac 100644 --- a/helm/ocaml/mathql_interpreter/mqint.ml +++ b/helm/ocaml/mathql_interpreter/mqint.ml @@ -327,7 +327,13 @@ and exec_boole_exp c = function (* 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 diff --git a/helm/ocaml/mathql_interpreter/relation.ml b/helm/ocaml/mathql_interpreter/relation.ml new file mode 100644 index 000000000..7e35aad75 --- /dev/null +++ b/helm/ocaml/mathql_interpreter/relation.ml @@ -0,0 +1,80 @@ +(* 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 +;; + diff --git a/helm/ocaml/mathql_interpreter/relation.mli b/helm/ocaml/mathql_interpreter/relation.mli new file mode 100644 index 000000000..392d670cf --- /dev/null +++ b/helm/ocaml/mathql_interpreter/relation.mli @@ -0,0 +1,27 @@ +(* 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 -- 2.39.2