X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=helm%2Focaml%2Fmathql%2FmQueryUtil.ml;fp=helm%2Focaml%2Fmathql%2FmQueryUtil.ml;h=349c2ac55038f6071aea89ddcddc8fddf1d346b1;hb=1c7fb836e2af4f2f3d18afd0396701f2094265ff;hp=3b16bb6b046d22a383b9c2f6bd03b5190a7dc6ed;hpb=2122459392680c4b53e32a2cf1d4792405f118ce;p=helm.git diff --git a/helm/ocaml/mathql/mQueryUtil.ml b/helm/ocaml/mathql/mQueryUtil.ml index 3b16bb6b0..349c2ac55 100644 --- a/helm/ocaml/mathql/mQueryUtil.ml +++ b/helm/ocaml/mathql/mQueryUtil.ml @@ -152,7 +152,6 @@ let text_of_query out x sep = | M.StatQuery x -> out "stat "; txt_set x | M.Keep b l x -> out "keep "; txt_allbut b; txt_path_list l; txt_set x - in txt_set x; out sep @@ -187,6 +186,36 @@ let stop_time (s0, u0) = let u1 = Unix.time () in Printf.sprintf "%.2fs,%.2fs" (s1 -. s0) (u1 -. u0) +(* operations on lists *****************************************************) + +type 'a comparison = Lt + | Gt + | Eq of 'a + +let list_join f l1 l2 = + let rec aux = function + | [], v + | v, [] -> v + | ((h1 :: t1) as v1), ((h2 :: t2) as v2) -> begin + match f h1 h2 with + | Lt -> h1 :: aux (t1, v2) + | Gt -> h2 :: aux (v1, t2) + | Eq h -> h :: aux (t1, t2) + end + in aux (l1, l2) + +let list_meet f l1 l2 = + let rec aux = function + | [], v + | v, [] -> [] + | ((h1 :: t1) as v1), ((h2 :: t2) as v2) -> begin + match f h1 h2 with + | Lt -> aux (t1, v2) + | Gt -> aux (v1, t2) + | Eq h -> h :: aux (t1, t2) + end + in aux (l1, l2) + (* conversion functions *****************************************************) type uriref = UriManager.uri * (int list)