blob: 6ab932e23b00881f4924a1d2eff1579691b767f9 (
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)
}
|