X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Flambda-delta%2Flib%2Fcps.ml;h=38b24903068c42a632c1f10e7002fcb16ebac653;hb=75d417a2bb12a56052dd520c513c789fd9256252;hp=c235197d960db9ab46bc508316f893e28e3d4703;hpb=f3b4d265268a43ca98e6843b733109fdfe3f6b0b;p=helm.git diff --git a/helm/software/lambda-delta/lib/cps.ml b/helm/software/lambda-delta/lib/cps.ml index c235197d9..38b249030 100644 --- a/helm/software/lambda-delta/lib/cps.ml +++ b/helm/software/lambda-delta/lib/cps.ml @@ -30,10 +30,10 @@ let rec list_rev_map_append f map ~tail = function let f hd = list_rev_map_append f map ~tail:(hd :: tail) tl in map f hd -let rec forall2 f map l1 l2 = match l1, l2 with +let rec list_forall2 f map l1 l2 = match l1, l2 with | [], [] -> f true | hd1 :: tl1, hd2 :: tl2 -> - let f b = if b then forall2 f map tl1 tl2 else f false in + let f b = if b then list_forall2 f map tl1 tl2 else f false in map f hd1 hd2 | _ -> f false @@ -46,6 +46,25 @@ let list_rev_map = let list_rev = list_rev_append ~tail:[] +let list_fold_right f map l a = + let map f a m = map f m a in + list_rev (list_fold_left f map a) l + let list_map f = list_rev_map (list_rev f) +let list_iter f map l = + let map f () x = map f x in + list_fold_left f map () l + +let rec list_fold_left2 f map a l1 l2 = match l1, l2 with + | [], [] -> f a + | hd1 :: tl1, hd2 :: tl2 -> + let f a = list_fold_left2 f map a tl1 tl2 in + map f a hd1 hd2 + | _ -> assert false + +let rec list_mem ?(eq=(=)) a = function + | [] -> false + | hd :: _ when eq a hd -> true + | _ :: tl -> list_mem ~eq a tl