diff --git a/src/core/CCFun.ml b/src/core/CCFun.ml index 65c9a5d59..1718aa7f1 100644 --- a/src/core/CCFun.ml +++ b/src/core/CCFun.ml @@ -8,8 +8,11 @@ include Sys include Stdlib include Fun +let[@inline] and_pred f g x = f x && g x +let[@inline] or_pred f g x = f x || g x let[@inline] compose f g x = g (f x) let[@inline] compose_binop f g x y = g (f x) (f y) + let[@inline] curry f x y = f (x, y) let[@inline] uncurry f (x, y) = f x y diff --git a/src/core/CCFun.mli b/src/core/CCFun.mli index fa69904f8..1c20937b5 100644 --- a/src/core/CCFun.mli +++ b/src/core/CCFun.mli @@ -5,6 +5,16 @@ include module type of Fun (** @inline *) +val and_pred : ('a -> bool) -> ('a -> bool) -> 'a -> bool +(** [and_p f g x] is [(f x) && (g x)]. + Produces a predicate which is a conjunction of the two predicates. +*) + +val or_pred : ('a -> bool) -> ('a -> bool) -> 'a -> bool +(** [or_p f g x] is [(f x) || (g x)]. + Produces a predicate which is a disjunction of the two predicates. +*) + val compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c (** [compose f g x] is [g (f x)]. Composition. *)