O'Reilly logo

Clojure for Finance by Timothy Washington

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

Working with lazy sequences

There's another subtle notion to grasp when we talk about infinite lazy sequences. If we normally assign (or bind, in this case) some list or collection, we expect those artifacts to have values right away. You may have noticed that even after binding pricelist and timeseries, nothing happened. This is to say that binding these two Vars didn't immediately compute any values from the aforementioned expressions. This is the main feature that laziness provides. Only when we needed to pull out values using, for example, (take 40 (generate-prices 5 15)) or (take 2 our-average), were the expressions actually run. This means that (def timeseries (generate-timeseries pricelist) bound a lazy sequence to the timeseries symbol. ...

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