summaryrefslogtreecommitdiff
path: root/test/files/run/iterator-concat.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/iterator-concat.scala')
-rw-r--r--test/files/run/iterator-concat.scala15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/files/run/iterator-concat.scala b/test/files/run/iterator-concat.scala
new file mode 100644
index 0000000000..f11363410f
--- /dev/null
+++ b/test/files/run/iterator-concat.scala
@@ -0,0 +1,15 @@
+object Test {
+ // Create `size` Function0s, each of which evaluates to an Iterator
+ // which produces 1. Then fold them over ++ to get a single iterator,
+ // which should sum to "size".
+ def mk(size: Int): Iterator[Int] = {
+ val closures = (1 to size).toList.map(x => (() => Iterator(1)))
+ closures.foldLeft(Iterator.empty: Iterator[Int])((res, f) => res ++ f())
+ }
+ def main(args: Array[String]): Unit = {
+ println(mk(100).sum)
+ println(mk(1000).sum)
+ println(mk(10000).sum)
+ println(mk(100000).sum)
+ }
+}