New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stream.collect isn't lazy #4294
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4294?orig=1 |
Atsuhiko Yamanaka (ymnk) said: $$ scala
Welcome to Scala version 2.9.0.r24358-b20110301020104 (Java HotSpot(TM) Client VM, Java 1.6.0_16).
Type in expressions to have them evaluated.
Type :help for more information.
scala> Stream.from(0, 1).collect{case x => x+1}
res0: scala.collection.immutable.Stream[Int] = Stream(0, ?)
scala> res0.take(10).toList
res1: List[Int] = List(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
IMHO, a fix for collectedTail method in r24351 is not correct; I mean pf has not been applied. It should be ... private[immutable] def collectedTail[A, B, That](stream: Stream[A], pf: PartialFunction[A, B], bf: CanBuildFrom[Stream[A], B, That]) = {
new Stream.Cons(pf(stream.head), stream.tail.collect(pf)(bf).asInstanceOf[Stream[B]])
} |
@axel22 said: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in both Scala 2.8.1 and Scala 2.9 (latest nightly), this loops until you run out of heap:
The text was updated successfully, but these errors were encountered: