CCOrd.map

This commit is contained in:
Simon Cruanes 2014-08-07 13:14:23 +02:00
parent 1f506eb243
commit e703a3f655
2 changed files with 10 additions and 0 deletions

View file

@ -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)

View file

@ -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. *)