X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Fcommon%2Fentity.ml;h=3aa1ef6b59cfb086430cd408d734d64ccc36898b;hb=7d9753115cb26bf27a739e9e1d753fd60b185c17;hp=292b1e921fc6bc349cc4d28aea170e5de03b228c;hpb=cd798346d31b14b8947e5801b87dc4f363607862;p=helm.git diff --git a/helm/software/lambda-delta/common/entity.ml b/helm/software/lambda-delta/common/entity.ml index 292b1e921..3aa1ef6b5 100644 --- a/helm/software/lambda-delta/common/entity.ml +++ b/helm/software/lambda-delta/common/entity.ml @@ -24,7 +24,7 @@ type 'term bind = Abst of 'term (* declaration: domain *) type 'term entity = attrs * uri * 'term bind (* attrs, name, binder *) -type 'a uri_generator = (string -> 'a) -> string -> 'a +type uri_generator = string -> string (* this could be in CPS *) (* helpers ******************************************************************) @@ -33,6 +33,27 @@ let rec name err f = function | _ :: tl -> name err f tl | [] -> err () +let names f map l a = + let rec aux f i a = function + | [] -> f a + | Name (n, r) :: tl -> aux (map f i n r) false a tl + | _ :: tl -> aux f i a tl + in + aux f true a l + +let rec get_name err f j = function + | [] -> err () + | Name (n, r) :: _ when j = 0 -> f n r + | Name _ :: tl -> get_name err f (pred j) tl + | _ :: tl -> get_name err f j tl + +let rec get_names f = function + | [] -> f [] [] + | Name _ as n :: tl -> + let f a ns = f a (n :: ns) in get_names f tl + | e :: tl -> + let f a = f (e :: a) in get_names f tl + let rec apix err f = function | Apix i :: _ -> f i | _ :: tl -> apix err f tl