I'm using Stream to create a lazy sequence. My sequence is combined from others sequences by ++. But my code does not work. Why?
def select[T1, T2](s: Stream[T1], map: T1=>T2): Stream[T2] = {
for (sv <- s) yield map(sv)
}
var innerCounter = 0
var proxy = (x: Int) => { innerCounter += 1; x }
var list: Stream[Int] = select[Int,Int](Stream.empty, k => k)
for (nc <- 0 until 10) {
list = select[Int,Int](Stream.empty, k => k)
var i: Int = 0
while (i < CountConcat) {
i += 1
list = list ++ select[Int,Int](Stream(0), k => proxy(i + 100))
}
}
assert(innerCounter == 0)