package containers

  1. Overview
  2. Docs
A modular, clean and powerful extension of the OCaml standard library

Install

Dune Dependency

Authors

Maintainers

Sources

v3.3.tar.gz
md5=aa946f452a156b7cd0b932b5a849b44e
sha512=fbb6e519ea918afd3895de4cb74bb93a1d7d8899aa1d9def0ee0576a4f648413e3a7d9639040a1117516efb74c66c3432e6da79e6284d2315327175e22766717

doc/containers/CCOrd/index.html

Module CCOrdSource

Comparisons

Sourcetype 'a t = 'a -> 'a -> int

Comparison (total ordering) between two elements, that returns an int.

Sourceval compare : 'a t

Polymorphic "magic" comparison.

Sourceval opp : 'a t -> 'a t

Opposite order.

Sourceval equiv : int -> int -> bool

Returns true iff the two comparison results are the same.

Sourceval int : int t
Sourceval string : string t
Sourceval bool : bool t
Sourceval float : float t

Lexicographic Combination

Sourceval (<?>) : int -> ('a t * 'a * 'a) -> int

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))
Sourceval option : 'a t -> 'a option t

Comparison of optional values. None is smaller than any Some _.

  • since 0.15
Sourceval pair : 'a t -> 'b t -> ('a * 'b) t
Sourceval triple : 'a t -> 'b t -> 'c t -> ('a * 'b * 'c) t
Sourceval list : 'a t -> 'a list t

Lexicographic combination on lists.

Sourceval array : 'a t -> 'a array t
Sourceval 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.

Sourceval (>|=) : 'b t -> ('a -> 'b) -> 'a t

Infix equivalent of map.

Sourcemodule Infix : sig ... end
OCaml

Innovation. Community. Security.