aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Arnaud Spiwack <arnaud@spiwack.net>2014-02-24 17:06:42 +0100
committerGravatar Arnaud Spiwack <arnaud@spiwack.net>2014-02-24 17:06:42 +0100
commitfba4a5db9769b3d31256d840923d76335adb64ba (patch)
treecaa1772c08a4f2386d16e34b089ca520986af46e
parentb565bb91802982ee67b4b580b68d6fb4c7f93335 (diff)
IStream: more efficient implementation of concat_map.
-rw-r--r--lib/iStream.ml6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/iStream.ml b/lib/iStream.ml
index bcb5336f2..065155f08 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))