liveBook · Manning

Lazy list

A lazy list is an immutable sequence whose elements and continuation are computed incrementally on demand, allowing finite or infinite sequences.

How 2 Manning books explain it

Clojure: The Essential Reference

A lazy sequence is a sequence whose elements are computed incrementally as they are requested.

How it is used
Uses incremental generation and processing to obtain a finite portion of large or infinite sequences.
How deep it goes
Explains delayed evaluation, caching, recursive construction, realization costs, head retention, and stack-overflow cases.
Examples
Uses infinite ranges, eager-versus-lazy mapping, prime generation, regular-expression matches, and JDBC rows.
What you can do after
Build it from scratch with `lazy-seq` and `cons`, and diagnose when consumption retains memory or outlives a resource.

Read how Clojure: The Essential Reference explains lazy list →

Functional Programming in Scala, Second Edition

A lazy list is an immutable sequence whose elements and continuation are evaluated on demand, allowing finite or infinite sequences.

How it is used
Uses demand-driven sequences to fuse transformations, avoid unnecessary allocation, and represent infinite computations.
How deep it goes
Explains thunk-based representation, selective forcing, stack safety, core operations, and stateful generation.
Examples
Demonstrates finite prefixes, infinite integer and constant streams, Fibonacci numbers, transformation chains, and REPL conversion with toList.
What you can do after
Build it from scratch using Scala thunks, lazy constructors, recursive operations, and unfold-based generators.

Read how Functional Programming in Scala, Second Edition explains lazy list →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.