From 5c7cfb7a934f9a581d6ddc530a4c6fb01cd58aa1 Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sat, 4 Oct 2014 19:18:34 +0200 Subject: A few improvements on pattern-matching compilation. - Optimize the removal of generalization when there is no dependency in the generalized variable (see postprocess_dependencies, and the removal of dependencies in the default type of impossible cases). - Compute the onlydflt flag correctly (what allows automatic treatment of impossible cases even when there is no clause at all). --- lib/cArray.ml | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/cArray.ml') diff --git a/lib/cArray.ml b/lib/cArray.ml index 81ac874775..1603454304 100644 --- a/lib/cArray.ml +++ b/lib/cArray.ml @@ -15,6 +15,7 @@ sig val equal : ('a -> 'a -> bool) -> 'a array -> 'a array -> bool val is_empty : 'a array -> bool val exists : ('a -> bool) -> 'a array -> bool + val exists2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool val for_all : ('a -> bool) -> 'a array -> bool val for_all2 : ('a -> 'b -> bool) -> 'a array -> 'b array -> bool val for_all3 : ('a -> 'b -> 'c -> bool) -> @@ -107,6 +108,14 @@ let exists f v = in exrec ((Array.length v)-1) +let exists2 f v1 v2 = + let rec exrec = function + | -1 -> false + | n -> f (uget v1 n) (uget v2 n) || (exrec (n-1)) + in + let lv1 = Array.length v1 in + lv1 = Array.length v2 && exrec (lv1-1) + let for_all f v = let rec allrec = function | -1 -> true -- cgit v1.2.3