Laziness

Learn about lazily evaluated sequences.

What is laziness or lazy evaluation?

The idea of laziness or lazy evaluation in programming languages is to make them more efficient. The evaluation process in most programming languages is automatically triggered when a compiler encounters an expression. It gets a piece of code and performs it to generate a result, even though it may not be used. This can consume a lot of memory and waste processing resources. Lazy evaluation is a possibility offered by some programming languages to try to overcome this wastage because it keeps the code without evaluating it unless it’s necessary.

How does Clojure use lazy evaluation?

Clojure is not a lazy language, so we can’t say that it does this process the whole time. But it has lazy sequences, and they’re widely used.

Lazy sequences

...
Access this course and 1400+ top-rated courses and projects.