Skip to content
Snippets Groups Projects
Commit 6b0acbf2 authored by Basile Desloges's avatar Basile Desloges
Browse files

[kernel] Add `nest` and `flatten` to `Extlib` to manipulate tuples

parent 5184387b
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,14 @@ let uncurry f x = f (fst x) (snd x)
let iter_uncurry2 iter f v =
iter (fun a b -> f (a, b)) v
(* ************************************************************************* *)
(** {2 Tuples} *)
(* ************************************************************************* *)
let nest b (a, c) = (a, b), c
let flatten ((a, b), c) = a, b, c
(* ************************************************************************* *)
(** {2 Lists} *)
(* ************************************************************************* *)
......
......@@ -77,6 +77,17 @@ val iter_uncurry2:
(('a -> 'b -> unit) -> 'c -> unit) ->
(('a * 'b -> unit) -> 'c -> unit)
(* ************************************************************************* *)
(** {2 Tuples} *)
(* ************************************************************************* *)
val nest: 'b -> 'a * 'c -> ('a * 'b) * 'c
(** Nest the first argument with the first element of the pair given as second
argument. *)
val flatten: ('a * 'b) * 'c -> 'a * 'b * 'c
(** Flatten the pairs into a triplet. *)
(* ************************************************************************* *)
(** {2 Lists} *)
(* ************************************************************************* *)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment