package containers

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

Install

Dune Dependency

Authors

Maintainers

Sources

v2.8.tar.gz
md5=03b80e963186e91ddac62ef645bf7fb2
sha512=c8f434808be540c16926bf03d89f394d33fc2d092f963a7b6d412481229e0a96290f1ad7c7d522415115d35426b7aa0b3fda4b991ddc321dad279d402c9a0c0b

doc/containers/CCPair/index.html

Module CCPairSource

Tuple Functions

Sourcetype ('a, 'b) t = 'a * 'b
Sourceval make : 'a -> 'b -> ('a, 'b) t

Make a tuple from its components.

  • since 0.16
Sourceval map1 : ('a -> 'b) -> ('a * 'c) -> 'b * 'c

map1 f (x, y) returns (f x, y).

Sourceval map2 : ('a -> 'b) -> ('c * 'a) -> 'c * 'b

map2 f (x, y) returns (x, f y).

Sourceval map : ('a -> 'c) -> ('b -> 'd) -> ('a * 'b) -> 'c * 'd

Synonym to (***). Map on both sides of a tuple.

Sourceval map_same : ('a -> 'b) -> ('a * 'a) -> 'b * 'b

Like map but specialized for pairs with elements of the same type.

Sourceval map_fst : ('a -> 'b) -> ('a * _) -> 'b

Compose the given function with fst.

  • since 0.3.3
Sourceval map_snd : ('a -> 'b) -> (_ * 'a) -> 'b

Compose the given function with snd.

  • since 0.3.3
Sourceval iter : ('a -> 'b -> unit) -> ('a * 'b) -> unit
Sourceval swap : ('a * 'b) -> 'b * 'a

Swap the components of the tuple.

Sourceval (<<<) : ('a -> 'b) -> ('a * 'c) -> 'b * 'c

Map on the left side of the tuple.

Sourceval (>>>) : ('a -> 'b) -> ('c * 'a) -> 'c * 'b

Map on the right side of the tuple.

Sourceval (***) : ('a -> 'c) -> ('b -> 'd) -> ('a * 'b) -> 'c * 'd

Map on both sides of a tuple.

Sourceval (&&&) : ('a -> 'b) -> ('a -> 'c) -> 'a -> 'b * 'c

f &&& g is fun x -> f x, g x. It splits the computations into two parts.

Sourceval merge : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c

Uncurrying (merges the two components of a tuple).

Sourceval fold : ('a -> 'b -> 'c) -> ('a * 'b) -> 'c

Synonym to merge.

  • since 0.3.3
Sourceval dup : 'a -> 'a * 'a

dup x = (x,x) (duplicate the value).

  • since 0.3.3
Sourceval dup_map : ('a -> 'b) -> 'a -> 'a * 'b

dup_map f x = (x, f x). Duplicates the value and applies the function to the second copy.

  • since 0.3.3
Sourceval equal : ('a -> 'a -> bool) -> ('b -> 'b -> bool) -> ('a * 'b) -> ('a * 'b) -> bool
Sourceval compare : ('a -> 'a -> int) -> ('b -> 'b -> int) -> ('a * 'b) -> ('a * 'b) -> int
Sourceval to_string : ?sep:string -> ('a -> string) -> ('b -> string) -> ('a * 'b) -> string

Print tuple in a string

  • since 2.7
Sourcetype 'a printer = Format.formatter -> 'a -> unit
Sourceval pp : ?sep:string -> 'a printer -> 'b printer -> ('a * 'b) printer

Print a pair given an optional separator and a method for printing each of its elements.

OCaml

Innovation. Community. Security.

On This Page
  1. Tuple Functions