I see at least two different implementations:
def add_streams(s1:Stream[Int], s2:Stream[Int]): Stream[Int] = Stream.cons(s1.head + s2.head, add_stream(s1.tail, s2.tail))
def add_streams(s1:Stream[Int], s2:Stream[Int]) =
(s1 zip s2) map {case (x,y) => x + y}
I guess the last one is more efficient since it is not recursive.
Is it correct? How would you code such a function ?