package containers
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=372df86e2a41e86c959c28a3392eb2ffd89754d1e5af2aaa09537654af57b1da
sha512=7d87d44065612095fa0342a9c95a2c4cfdf73d5af47c6fce24262cf2870c36dee70ebecd056113aa9c1643256bc032c08530f5083061c44602c0da5a132c2d6c
doc/containers/CCOrd/index.html
Module CCOrd
Source
Order combinators
Comparisons
Comparison (total ordering) between two elements, that returns an int.
Opposite order. For example, opp cmp a b < 0
iff cmp b a > 0
. This can be used to sort values in the opposite order, among other things.
Returns true
iff the two comparison results are the same.
Lexicographic Combination
c1 <?> (ord, x, y)
returns the same as c1
if c1
is not 0
; otherwise it uses ord
to compare the two values x
and y
, 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))
Comparison of optional values. None
is smaller than any Some _
.
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.