base

Full standard library replacement for OCaml
IN THIS PACKAGE
Module type Base . Comparable . With_compare
val lexicographic : ( 'a -> 'a -> int ) list -> 'a -> 'a -> int

lexicographic cmps x y compares x and y lexicographically using functions in the list cmps.

val lift : ( 'a -> 'a -> 'result ) -> f:( 'b -> 'a ) -> 'b -> 'b -> 'result

lift cmp ~f x y compares x and y by comparing f x and f y via cmp.

val reverse : ( 'a -> 'a -> 'result ) -> 'a -> 'a -> 'result

reverse cmp x y = cmp y x

Reverses the direction of asymmetric relations by swapping their arguments. Useful, e.g., for relations implementing "is a subset of" or "is a descendant of".

Where reversed relations are already provided, use them directly. For example, Comparable.S provides ascending and descending, which are more readable as a pair than compare and reverse compare. Similarly, <= is more idiomatic than reverse (>=).

The functions below are analogues of the type-specific functions exported by the Comparable.S interface.

val equal : ( 'a -> 'a -> int ) -> 'a -> 'a -> bool
val max : ( 'a -> 'a -> int ) -> 'a -> 'a -> 'a
val min : ( 'a -> 'a -> int ) -> 'a -> 'a -> 'a