mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-07 03:35:30 -05:00
CCFun.on_top_of (binary composition)
This commit is contained in:
parent
54d16494b0
commit
af850a88c1
2 changed files with 11 additions and 3 deletions
|
|
@ -40,6 +40,8 @@ let (@@) f x = 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 curry f x y = f (x,y)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,12 @@ val (|>) : 'a -> ('a -> 'b) -> 'b
|
|||
val compose : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
|
||||
(** 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
|
||||
(** Alias to [compose] *)
|
||||
|
||||
|
|
@ -68,7 +74,7 @@ val lexicographic : ('a -> 'a -> int) -> ('a -> 'a -> int) -> 'a -> 'a -> int
|
|||
(** Lexicographic combination of comparison functions *)
|
||||
|
||||
val finally : h:(unit -> unit) -> f:(unit -> 'a) -> 'a
|
||||
(** [finally h f] calls [f ()] and returns its result. If it raises, the
|
||||
(** [finally h f] calls [f ()] and returns its result. If it raises, the
|
||||
same exception is raised; in {b any} case, [h ()] is called after
|
||||
[f ()] terminates. *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue