val bigIntFromStream : Stream[BigInt] = BigInt(0) #:: BigInt(1) #:: bigIntFromStream.zip(bigIntFromStream.tail).map{x =>
println(s"stream = ${bigIntFromStream} + stream.tail = ${bigIntFromStream.tail} + zipped value = ${bigIntFromStream.zip(bigIntFromStream.tail)}")
println(s"Calculating value for ${x}, {x._1} = ${x._1}, {x._2} = ${x._2}")
x._1 + x._2}
代码的输出如下
0 1 stream = Stream(0, 1, ?) + stream.tail = Stream(1, ?) + zipped value = Stream((0,1), ?)
Calculating value for (0,1), {x._1} = 0, {x._2} = 1
1 stream = Stream(0, 1, 1, ?) + stream.tail = Stream(1, 1, ?) + zipped value = Stream((0,1), ?)
Calculating value for (1,1), {x._1} = 1, {x._2} = 1
2 stream = Stream(0, 1, 1, 2, ?) + stream.tail = Stream(1, 1, 2, ?) + zipped value = Stream((0,1), ?)
Calculating value for (1,2), {x._1} = 1, {x._2} = 2
3 stream = Stream(0, 1, 1, 2, 3, ?) + stream.tail = Stream(1, 1, 2, 3, ?) + zipped value = Stream((0,1), ?)
Calculating value for (2,3), {x._1} = 2, {x._2} = 3
5 stream = Stream(0, 1, 1, 2, 3, 5, ?) + stream.tail = Stream(1, 1, 2, 3, 5, ?) + zipped value = Stream((0,1), ?)
Calculating value for (3,5), {x._1} = 3, {x._2} = 5
我的问题是x如何得到实际值和尾部之间的最后一个zip值?如果我遗漏了什么,请告诉我