package containers
Install
Dune Dependency
Authors
Maintainers
Sources
md5=58298b6d26c5198157e19b583e9eca2c
sha512=70f99a062f7696d4ed7a6336532261c93c49a9858a84a12f7f3d60190a5c664198e70be6281dc7c7932c07325dc9c579ff521367e4c7e083566910ba0f9ea760
doc/containers/CCPair/index.html
Module CCPair
Source
Tuple Functions
map_fst f (x, y)
returns (f x, y)
. Renamed from map1
since 3.0.
map_snd f (x, y)
returns (x, f y)
. Renamed from map2
since 3.0.
Synonym to (***)
. Map on both sides of a tuple.
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 * 'c2
map2 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.
Swap the components of the tuple.
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