X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2Fmatita%2Fcontribs%2Flambdadelta%2Fbin%2Froles%2FrolesUtils.ml;h=ae8dc9fe0beea34def9771f3e81085da6ce0d14e;hb=7666f9dddfcaca5671dd25d3cd2095481968c7bf;hp=dcf7addef89f3c139cbfa6f47ddc531e198c362b;hpb=9bb0e91ff4c24ae6e51cac336b9edd6d6bf1ed0d;p=helm.git diff --git a/matita/matita/contribs/lambdadelta/bin/roles/rolesUtils.ml b/matita/matita/contribs/lambdadelta/bin/roles/rolesUtils.ml index dcf7addef..ae8dc9fe0 100644 --- a/matita/matita/contribs/lambdadelta/bin/roles/rolesUtils.ml +++ b/matita/matita/contribs/lambdadelta/bin/roles/rolesUtils.ml @@ -74,6 +74,10 @@ let rec list_exists compare = function if b <= 0 then b = 0 else list_exists compare tl +let rec list_count s c = function + | [] -> s, c + | (b, _)::tl -> list_count (s + if b then 1 else 0) (succ c) tl + let string_of_version v = String.concat "." (List.map string_of_int v) @@ -149,12 +153,38 @@ let rec get_tops v = function end else ds, ts +let rec match_names oi ni os ns = + match os, ns with + | _ , [] -> None + | [] , _ -> None + | (_,o)::otl,(_,n)::ntl -> + let b = compare_names (snd o) n in + if b > 0 then match_names oi (succ ni) os ntl else + if b < 0 then match_names (succ oi) ni otl ns else + Some (oi, ni) + let new_status = { ET.r = []; ET.s = []; ET.t = []; ET.w = []; } +let string_of_pointer = string_of_version + let pointer_of_string = version_of_string +let list_visit before each after string_of p l = + let ptr p = string_of_pointer (List.rev p) in + let rec aux i = function + | [] -> () + | (b, x)::tl -> + each (ptr (i::p)) b (string_of x); + aux (succ i) tl + in + let s, c = list_count 0 0 l in + let count = Printf.sprintf "%u/%u" s c in + before (ptr p) count; + aux 0 l; + after () + let string_of_error = function | ET.EWrongExt x -> Printf.sprintf "unknown input file type %S" x