The Ultimately Lazy Streams
Placing a lazy view on a strict collection doesn’t change the collection; it helps delay executing operations to the last possible moment. In other words, with a lazy view the values may all be in there; you simply won’t process them urgently or eagerly. A Stream is lazy to the bone—it produces values only on demand.
That may sound odd at first and may raise a number of questions: how many values would it hold, when does it create it, how do we get the values? A stream may be finite or infinite—that’s right, an infinite series. Wait a minute, if it is infinite in size, then how could we possibly store it on our machines, with the limited amount of memory we have? Well, now you know what this cloud computing is all ...
Get Pragmatic Scala now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.