From 9bcc410c368420883457f6671ae8e7c1851e6398 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 20 May 2014 20:10:09 +0200 Subject: [PATCH] better CCKlist.flat_map --- core/CCKList.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/CCKList.ml b/core/CCKList.ml index a9a5fe81..897a9409 100644 --- a/core/CCKList.ml +++ b/core/CCKList.ml @@ -120,5 +120,9 @@ let rec append l1 l2 = match l1 with let rec flat_map f l = match l with | `Nil -> `Nil | `Cons (x, l') -> - append (f x) (flat_map f (l' ())) + _flat_map_app f (f x) (l' ()) () +and _flat_map_app f l l' () = match l with + | `Nil -> flat_map f l' + | `Cons (x, tl) -> + `Cons (x, _flat_map_app f (tl ()) l')