O'Reilly logo

Clojure Programming Cookbook by Nicolas Modrzyk, Makoto Hashimoto

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

How to become lazy

As you may know, laziness is a simple concept. It is the act of only doing the minimum required, or to postpone work until the very last moment. This is a conscious choice, and therefore must be applied with care.

One of the reasons Clojure is enjoyable as a programming language is because it makes it easy to be lazy; or, in simple computing terms, it only evaluates the minimum needed, when it is needed. Nothing extra.

So, why would you want to be lazy, or in other words, build lazy sequences? Obviously, to avoid unnecessary computations. An example of this is, say, if you have a mathematical formula or a repeating function defining a list of elements and you only want to use some of those elements. This is when you want to write ...

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