blob: 1a906cd9bc42e3301b0875ce56d5b3dc8aeed1bf (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
|
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).elements)
assert(sum(str) == 6)
}
|