blob: 7d4c59d94c86d2573cabd99e2db4481b114b3bf0 (
plain) (
tree)
|
|
object Test {
def sum(stream: Stream[Int]): Int =
stream match {
case Stream.Empty => 0
case Stream.cons(hd, tl) => hd + sum(tl)
}
val str: Stream[Int] = Stream.fromIterator(List(1,2,3).iterator)
assert(sum(str) == 6)
}
|