Module CCOrd
Comparisons
val poly : 'a tPolymorphic "magic" comparison. Use with care, as it will fail on some types.
- since
- NEXT_RELEASE
val compare : 'a tPolymorphic "magic" comparison.
- deprecated
since NEXT_RELEASE in favor of
poly. The reason is thatcompareis easily shadowed, can shadow other comparators, and is just generally not very descriptive.
val opp : 'a t -> 'a tOpposite order. For example,
opp cmp a b < 0iffcmp b a > 0. This can be used to sort values in the opposite order, among other things.
Lexicographic Combination
val (<?>) : int -> ('a t * 'a * 'a) -> intc1 <?> (ord, x, y)returns the same asc1ifc1is not0; otherwise it usesordto compare the two valuesxandy, 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 tComparison of optional values.
Noneis smaller than anySome _.- since
- 0.15
val pair : 'a t -> 'b t -> ('a * 'b) tval triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) tval list : 'a t -> 'a list tLexicographic combination on lists.
val array : 'a t -> 'a array tval map : ('a -> 'b) -> 'b t -> 'a tmap f ordis the comparison function that, given objectsxandy, projectsxandyusingf(e.g. using a record field) and then compares those projections withord. Example:map fst CCInt.comparecompares values of type(int * 'a)by their first component.
module Infix : sig ... end