CCPairSourceTuple Functions
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).
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.
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