]> matita.cs.unibo.it Git - helm.git/commitdiff
After add relation.ml relation.mli
authornatile <??>
Tue, 1 Oct 2002 16:26:58 +0000 (16:26 +0000)
committernatile <??>
Tue, 1 Oct 2002 16:26:58 +0000 (16:26 +0000)
helm/ocaml/mathql_interpreter/mqint.ml
helm/ocaml/mathql_interpreter/relation.ml [new file with mode: 0644]
helm/ocaml/mathql_interpreter/relation.mli [new file with mode: 0644]

index 95d3c8f2e47f9b5aa37e17e000a87b49ab508630..688158faca551b87c1e8aa2fa3d663d75595c2a3 100644 (file)
@@ -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 (file)
index 0000000..7e35aad
--- /dev/null
@@ -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 (file)
index 0000000..392d670
--- /dev/null
@@ -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