Module CCOrd
Comparisons
val compare : 'a t
Polymorphic "magic" comparison.
Lexicographic Combination
val (<?>) : int -> ('a t * 'a * 'a) -> int
c1 <?> (ord, x, y)
returns the same asc1
ifc1
is not0
; otherwise it usesord
to compare the two valuesx
andy
, of type'a
.Example:
CCInt.compare 1 3 <?> (String.compare, "a", "b") <?> (CCBool.compare, true, false)
Same example, using only CCOrd::
CCOrd.(int 1 3 <?> (string, "a", "b") <?> (bool, true, false))
val option : 'a t -> 'a option t
Comparison of optional values.
None
is smaller than anySome _
.- since
- 0.15
val pair : 'a t -> 'b t -> ('a * 'b) t
val triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
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 objectsx
andy
, projectsx
andy
usingf
(e.g. using a record field) and then compares those projections withord
. Example:map fst CCInt.compare
compares values of type(int * 'a)
by their first component.
module Infix : sig ... end