From fba4a5db9769b3d31256d840923d76335adb64ba Mon Sep 17 00:00:00 2001 From: Arnaud Spiwack Date: Mon, 24 Feb 2014 17:06:42 +0100 Subject: IStream: more efficient implementation of concat_map. --- lib/iStream.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/iStream.ml b/lib/iStream.ml index bcb5336f23..065155f081 100644 --- a/lib/iStream.ml +++ b/lib/iStream.ml @@ -77,4 +77,8 @@ let rec concat_node = function and concat (s : 'a t t) = lazy (concat_node (Lazy.force s)) -let concat_map f l = concat (map f l) +let rec concat_map_node f = function +| Nil -> Nil +| Cons (x,s) -> app_node (Lazy.force (f x)) (concat_map f s) + +and concat_map f l = lazy (concat_map_node f (Lazy.force l)) -- cgit v1.2.3