package containers
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=52eeff91ce42b52305e6aaa8a58b88ce8f0a5a984199e59ca7e2fd9ebabe61d7
sha512=dc7337e6cbc9850542c7c9228d3bcb4e4add57a55e2a2992f21fb4761b3e10a68ef1d57ca37a7f5b303fc875fe3df5ecb69dbf2930bfcd1561ce03f7ae83e24b
doc/containers/CCPair/index.html
Module CCPairSource
Tuple Functions
Pairs
The type for pairs.
make a b is the pair (a, b).
fst (a, b) is a.
snd (a, b) is b.
swap (a, b) is (b, a).
Iterators
fold f (a, b) applies f to a and b.
map f g (a, b) applies f to a and g to b.
iter f g (a, b) first applies f to a, and then g to b.
map_fst f p applies f to p's first component.
map_snd f p applies f to p's second component.
Predicates and comparisons
equal eqa eqb (a1, b1) (a2, b2) is true if and only if eqa a1 a2 and eqb b1 b2 are both true.
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.
Like map but specialized for pairs with elements of the same type.
val map2 :
('a1 -> 'b1 -> 'c1) ->
('a2 -> 'b2 -> 'c2) ->
('a1 * 'a2) ->
('b1 * 'b2) ->
'c1 * 'c2map2 f g (a,b) (x,y) return (f a x, g b y).
map_same2 f (a,b) (x,y) return (f a x, f b y).
Compose the given function with fst. Rename from map_fst since 3.0.
Compose the given function with snd. Rename from map_snd since 3.0.
Map on the left side of the tuple.
Map on the right side of the tuple.
Map on both sides of a tuple.
f &&& g is fun x -> f x, g x. It splits the computations into two parts.
Uncurrying (merges the two components of a tuple).
dup x = (x,x) (duplicate the value).
dup_map f x = (x, f x). Duplicates the value and applies the function to the second copy.
Print tuple in a string