CCFun.on_top_of (binary composition)

This commit is contained in:
Simon Cruanes 2014-11-19 14:49:51 +01:00
parent 54d16494b0
commit af850a88c1
2 changed files with 11 additions and 3 deletions

View file

@ -40,6 +40,8 @@ let (@@) f x = f x
let compose f g x = g (f x) let compose f g x = g (f x)
let compose_binop f g x y = g (f x) (f y)
let flip f x y = f y x let flip f x y = f y x
let curry f x y = f (x,y) let curry f x y = f (x,y)

View file

@ -32,6 +32,12 @@ val (|>) : 'a -> ('a -> 'b) -> 'b
val compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c val compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
(** Composition *) (** Composition *)
val compose_binop : ('a -> 'b) -> ('b -> 'b -> 'c) -> 'a -> 'a -> 'c
(** [compose_binop f g] is [fun x y -> g (f x) (f y)]
Example (partial order):
[List.sort (compose_binop fst CCInt.compare) [1, true; 2, false; 1, false]]
@since NEXT_RELEASE*)
val (%>) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c val (%>) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
(** Alias to [compose] *) (** Alias to [compose] *)