Does isEmpty method in Stream evaluate the whole Stream?
- by abhin4v
In Scala, does calling isEmtpy method on an instance of Stream class cause the stream to be evaluated completely? My code is like this:
import Stream.cons
private val odds: Stream[Int] = cons(3, odds.map(_ + 2))
private val primes: Stream[Int] = cons(2, odds filter isPrime)
private def isPrime(n: Int): Boolean = n match {
case 1 => false
…