From db9722608187bab2f8316792ae9cc70312648073 Mon Sep 17 00:00:00 2001 From: Nicola Mometto Date: Tue, 6 Mar 2018 10:48:39 +0000 Subject: [PATCH] Add optional transform function to CCLazy_list.of_list --- src/iter/CCLazy_list.ml | 4 ++-- src/iter/CCLazy_list.mli | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/iter/CCLazy_list.ml b/src/iter/CCLazy_list.ml index d4855bd9..1c21f8c8 100644 --- a/src/iter/CCLazy_list.ml +++ b/src/iter/CCLazy_list.ml @@ -102,9 +102,9 @@ let rec of_gen g = Q.(list int) (fun l -> l = (Gen.of_list l |> of_gen |> to_list)) *) -let rec of_list = function +let rec of_list ?(f = fun x -> x) = function | [] -> empty - | x :: tl -> cons x (of_list tl) + | x :: tl -> cons (f x) (of_list ~f tl) let to_list_rev l = let rec aux acc = function diff --git a/src/iter/CCLazy_list.mli b/src/iter/CCLazy_list.mli index b6111661..1e147460 100644 --- a/src/iter/CCLazy_list.mli +++ b/src/iter/CCLazy_list.mli @@ -56,7 +56,7 @@ type 'a gen = unit -> 'a option val of_gen : 'a gen -> 'a t -val of_list : 'a list -> 'a t +val of_list : ?f:('a -> 'b) -> 'a list -> 'b t val to_list : 'a t -> 'a list