O'Reilly logo

Learning Functional Data Structures and Algorithms by Raju Kumar Mishra, Atul Khot

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Streams

A stream is generally a lazy and linear sequence collection. Stream elements are evaluated only when needed. Streams are already defined in Scala and Clojure. Since elements of a stream are evaluated lazily, it can be of infinite length. In this section, we will explore streams in Scala and Clojure. Let me start with stream in Scala. List, which we are going to explore in the coming chapter, differs from stream only in lazy computation. Other properties of list are similar to stream.

Stream in Scala

Stream is a class defined in Scala. Stream constructor can be used to create Stream object. Stream elements are evaluated when they are required. Stream-calculated values are cached so that they can be used further. Let us explorer the characteristics ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required