diff options
| author | Hugo Herbelin | 2014-10-04 19:18:34 +0200 |
|---|---|---|
| committer | Hugo Herbelin | 2014-10-05 00:17:14 +0200 |
| commit | 5c7cfb7a934f9a581d6ddc530a4c6fb01cd58aa1 (patch) | |
| tree | 127e7fbedfec3ac3d9cfa420754e8b192ebd2942 /lib/cArray.ml | |
| parent | c22ccd90ec45099a2e97620f32ed89e0b81daa96 (diff) | |
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).
Diffstat (limited to 'lib/cArray.ml')
| -rw-r--r-- | lib/cArray.ml | 9 |
1 files changed, 9 insertions, 0 deletions
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 |
