blob: c903f19867fe17d15f9d906d85cd0a0fcd0c668c (
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] = List(1,2,3).iterator.toStream
assert(sum(str) == 6)
}
|