Pair
This module provides functions to work with pairs, which are 2-element tuples.
compare
RES
let compare: (
('a, 'b),
('c, 'd),
('a, 'c) => float,
('b, 'd) => float,
) => floatcompare(pair1, pair2, f1, f2) compares two pairs, using f1 to compare the first element
and f2 to compare the second element. Ordering is based on the first element,
if they are equal, the second element is compared.
Examples
RESPair.compare((1, "a"), (1, "a"), Int.compare, String.compare) == Ordering.equal
Pair.compare((1, "a"), (1, "b"), Int.compare, String.compare) == Ordering.less
Pair.compare((2, "a"), (1, "b"), Int.compare, String.compare) == Ordering.greater
equal
RES
let equal: (
('a, 'b),
('c, 'd),
('a, 'c) => bool,
('b, 'd) => bool,
) => boolequal(pair1, pair2, f1, f2) check equality of pair2 and pair2 using f1 for
equality on the first element and f2 for equality on the second element.
Examples
RESPair.equal((1, "test"), (1, "test"), Int.equal, String.equal) == true
Pair.equal((1, "test"), (2, "test"), Int.equal, String.equal) == false
first
RES
let first: (('a, 'b)) => 'aignore
RES
let ignore: ('a, 'b) => unitignore(pair) ignores the provided pair and returns unit.
This helper is useful when you want to discard a value (for example, the result of an operation with side effects) without having to store or process it further.
second
RES
let second: (('a, 'b)) => 'bt
RES
type t<'a, 'b> = ('a, 'b)