mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
CCOrd.map
This commit is contained in:
parent
1f506eb243
commit
e703a3f655
2 changed files with 10 additions and 0 deletions
|
|
@ -89,3 +89,5 @@ let array_ ord a1 a2 =
|
|||
then aux (i+1) else c
|
||||
in
|
||||
aux 0
|
||||
|
||||
let map f ord a b = ord (f a) (f b)
|
||||
|
|
|
|||
|
|
@ -64,3 +64,11 @@ val list_ : 'a t -> 'a list t
|
|||
(** Lexicographic combination on lists *)
|
||||
|
||||
val array_ : 'a t -> 'a array t
|
||||
|
||||
val map : ('a -> 'b) -> 'b t -> 'a t
|
||||
(** [map f ord] is the comparison function that, given objects [x] and [y],
|
||||
projects [x] and [y] using [f] (e.g. using a record field) and then
|
||||
compares those projections with [ord].
|
||||
Example:
|
||||
[map fst CCInt.compare] compares values of type [(int * 'a)] by their
|
||||
first component. *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue