Prelude.PairUseful functions on 2-tuples.
(of_list [a;b]) is the pair (a,b); a list of any length other than 2 raises invalid_arg _.
(map f (a,b)) is (f a, f b): applies the same function to each element of the pair.
(iter f (a,b)) is (f a, f b): applies the same function to each element of the pair, for side-effect.
(cross f g (a,b)) is (f a, g b): applies two different functions, one to each element of the pair.
(cross succ pred (1,1)) = (2,0) (&&&) is Pair.cross.
(diag f g x) is (f x, g x): applies two different functions to the same value, returning a pair of results.
(diag succ pred x) = (cross succ pred (x,x)) ( *** ) is Pair.diag.
(cartesian_product x y) is the Cartesian product of the two pairs.
cartesian_product (a,b) (c,d) = [a,c; a,d; b,c; b,d] ( * ) is cartesian_product.
val to_string :
?left:string ->
?sep:string ->
?right:string ->
('a -> string) ->
('b -> string) ->
('a * 'b) ->
string(to_string ?left ?sep ?right f g (a,b)) returns a string representation of (a,b).
f is used for the string representation of a and g for b.
The representation of the two values is inserted between ?left (default: "(") and ?right (default: ")"), separated by ?sep (default: ", ").
Example: (to_string string_of_int id (12,"foo")) = {|(12, "foo")|}
val print :
?left:string ->
?sep:string ->
?right:string ->
('a -> string) ->
('b -> string) ->
('a * 'b) ->
unit(print ?left ?sep ?right f g) is (to_string ?left ?sep ?right f g >> print_endline).
(random r1 r2) is a random pair of values (v1,v2) s.t. (v1 = r1 ()) and (v2 = r2 ()).
module Ops : sig ... endInfix and prefix operators.