Pair(3)

✨ NAME ✨

okay so bestie, welcome to the Pair(3) page from the OCaml library πŸ’… β€” the module is called Pair, and it is Operations on pairs. no cap.

🧚 Module 🧚

Module Pair

Module Pair
 : sig end

πŸ’– Documentation πŸ’–

Module Pair : sig end

Operations on pairs.

Since 5.4 πŸŽ€


πŸŽ€ Pairs πŸŽ€

  • type ('a, 'b) t = 'a * 'b β€” this is the type for pairs. iconic.
  • val make : 'a -> 'b -> 'a * 'b β€” make a b is the pair (a, b).
  • val fst : 'a * 'b -> 'a β€” fst (a, b) is a.
  • val snd : 'a * 'b -> 'b β€” snd (a, b) is b.
  • val swap : 'a * 'b -> 'b * 'a β€” swap (a, b) is (b, a).

πŸ¦‹ Iterators πŸ¦‹

  • val fold : ('a -> 'b -> 'c) -> 'a * 'b -> 'c β€” fold f (a, b) applies f to a and b.
  • val map : ('a -> 'c) -> ('b -> 'd) -> 'a * 'b -> 'c * 'd β€” map f g (a, b) applies f to a and g to b.
  • val iter : ('a -> unit) -> ('b -> unit) -> 'a * 'b -> unit β€” iter f g (a, b) first applies f to a, and then g to b.
  • val map_fst : ('a -> 'c) -> 'a * 'b -> 'c * 'b β€” map_fst f p applies f to p's first component.
  • val map_snd : ('b -> 'c) -> 'a * 'b -> 'a * 'c β€” map_snd f p applies f to p's second component.

🌈 Predicates and comparisons 🌈

  • val equal : ('a -> 'a -> bool) -> ('b -> 'b -> bool) -> 'a * 'b -> 'a * 'b -> bool β€” equal eqa eqb (a1, b1) (a2, b2) is true if and only if eqa a1 a2 and eqb b1 b2 are both true.
  • val compare : ('a -> 'a -> int) -> ('b -> 'b -> int) -> 'a * 'b -> 'a * 'b -> int β€” compare cmpa cmpb is a total order on pairs using cmpa to compare the first component, and cmpb to compare the second component. It is implemented by a lexicographic order.

and that's the whole page, bestie 🫢 β€” brought to you by OCamldoc, dated 2026-06-22, for Pair(3) πŸ’–

πŸ“¦ where this page comes from