diff options
author | Paul Phillips <paulp@improving.org> | 2012-10-29 20:20:35 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-11-01 05:12:20 -0700 |
commit | 4e4060f4faee791759417f1a598322e90623464d (patch) | |
tree | d4811f011a486e04761839d32c1942121008c3c1 /test/files | |
parent | 8a537b7d7da03833946a6a2f4461da2080363c88 (diff) | |
download | scala-4e4060f4faee791759417f1a598322e90623464d.tar.gz scala-4e4060f4faee791759417f1a598322e90623464d.tar.bz2 scala-4e4060f4faee791759417f1a598322e90623464d.zip |
Implementation of Stream#dropRight.
"There's nothing we can do about dropRight," you say?
Oh but there is.
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/run/streams.check | 1 | ||||
-rw-r--r-- | test/files/run/streams.scala | 5 |
2 files changed, 5 insertions, 1 deletions
diff --git a/test/files/run/streams.check b/test/files/run/streams.check index 7f894052d9..032057d4a1 100644 --- a/test/files/run/streams.check +++ b/test/files/run/streams.check @@ -23,3 +23,4 @@ Stream(100001, ?) true true 705082704 +6 diff --git a/test/files/run/streams.scala b/test/files/run/streams.scala index 51b4e5d76c..dc5d0204ac 100644 --- a/test/files/run/streams.scala +++ b/test/files/run/streams.scala @@ -29,7 +29,7 @@ object Test extends App { def powers(x: Int) = if ((x&(x-1)) == 0) Some(x) else None println(s3.flatMap(powers).reverse.head) - // large enough to generate StackOverflows (on most systems) + // large enough to generate StackOverflows (on most systems) // unless the following methods are tail call optimized. val size = 100000 @@ -43,4 +43,7 @@ object Test extends App { println(Stream.from(1).take(size).foldLeft(0)(_ + _)) val arr = new Array[Int](size) Stream.from(1).take(size).copyToArray(arr, 0) + + // dropRight terminates + println(Stream from 1 dropRight 1000 take 3 sum) } |