Eager Transformations
While lazy sequences are the right solution in many cases, they’re not the best answer in every case. An eager approach can be better when we wish to construct an output collection rather than a sequence, optimize memory and performance for transformations of large collections, or control external resources.
Producing Output Collections
Sequence transformations produce output only as needed, which allows us to avoid unnecessary work and even to work with infinite sequences. However, it’s also common to encounter situations where we want our output to be a persistent collection, not a sequence. In this case, we want all of the transformation to be completed, so we won’t get any advantage from laziness.
For example, consider ...