What are some internal details of handling a lazy-evaluated expression in a Scala stream?
This is a less practical question than "what's going on behind the scenes"? question. I'm trying to better understand what's going on under the hood in Scala when the expression "fib.tail.tail.tail" is evaluated in the context of the following function definition:
lazy val fib:Stream[Long]=
Stream.cons(1,
Stream.cons(2, fib.zip(fib.tail).
map(x=>x._1+x._2)))
I think my mental picture is correct, but I would really appreciate if someone with deeper Scala experience can criticize it and tell me what is missing or wrong. Here's a diagram that illustrates my "mental model":
Thank you in advance for your guidance!
+3
source to share
No one has answered this question yet
Check out similar questions: