Chapter 9. Working with laziness

This chapter covers

  • Understanding the importance of laziness
  • Implementing laziness in Java
  • Creating a lazy list data structure: the Stream
  • Optimizing lazy lists by memoizing evaluated values
  • Handling infinite streams

Some languages are said to be lazy, while others are not. Does this mean that some languages work harder than others? Not at all. Laziness is opposed to strictness. It has nothing to do with how hard a language can work, although you could sometimes think of lazy languages as languages that don’t require the programmer to work as hard as they must with strict ones.

Laziness, as you’ll see, has many advantages for some specific problems, such as composing infinite data structures and evaluating ...

Get Functional Programming in Java 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.