diff options
author | letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2013-10-24 09:41:19 +0000 |
---|---|---|
committer | letouzey <letouzey@85f007b7-540e-0410-9357-904b9bb8a0f7> | 2013-10-24 09:41:19 +0000 |
commit | a3a5711d8c2f9f0e12ed707c8b69c828e30bbcf4 (patch) | |
tree | 02972edf2946cbb9f4a30133d9f66dd5cdbe7987 /lib | |
parent | bb5e6d7c39211349d460db0b61b2caf3d099d5b6 (diff) |
Turn many List.assoc into List.assoc_f
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@16925 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cList.ml | 5 | ||||
-rw-r--r-- | lib/cList.mli | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/cList.ml b/lib/cList.ml index db2aa2bcf..6559efd40 100644 --- a/lib/cList.ml +++ b/lib/cList.ml @@ -131,6 +131,7 @@ sig val map_assoc : ('a -> 'b) -> ('c * 'a) list -> ('c * 'b) list val assoc_f : 'a eq -> 'a -> ('a * 'b) list -> 'b val remove_assoc_f : 'a eq -> 'a -> ('a * 'b) list -> ('a * 'b) list + val mem_assoc_f : 'a eq -> 'a -> ('a * 'b) list -> bool val cartesian : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list val cartesians : ('a -> 'b -> 'b) -> 'b -> 'a list list -> 'b list val combinations : 'a list list -> 'a list list @@ -735,7 +736,9 @@ let rec assoc_f f a = function | (x, e) :: xs -> if f a x then e else assoc_f f a xs | [] -> raise Not_found -let remove_assoc_f f a l = remove_first (fun (x,y) -> f a x) l +let remove_assoc_f f a l = remove_first (fun (x,_) -> f a x) l + +let mem_assoc_f f a l = List.exists (fun (x,_) -> f a x) l (* A generic cartesian product: for any operator (**), [cartesian (**) [x1;x2] [y1;y2] = [x1**y1; x1**y2; x2**y1; x2**y1]], diff --git a/lib/cList.mli b/lib/cList.mli index 60110228a..3968a4adf 100644 --- a/lib/cList.mli +++ b/lib/cList.mli @@ -217,6 +217,7 @@ sig val map_assoc : ('a -> 'b) -> ('c * 'a) list -> ('c * 'b) list val assoc_f : 'a eq -> 'a -> ('a * 'b) list -> 'b val remove_assoc_f : 'a eq -> 'a -> ('a * 'b) list -> ('a * 'b) list + val mem_assoc_f : 'a eq -> 'a -> ('a * 'b) list -> bool val cartesian : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list (** A generic cartesian product: for any operator (**), |