Core concept

val nats = LazyList.from(1)
nats.take(5).toList  // List(1, 2, 3, 4, 5)
Advertisement

How it works

Memory leak if hold reference to head. Careful with .force.

Advertisement

Trade-offs + gotchas

Infinite sequences. Lazy pipelines.