Fascinating deep dive into the relationship between full laziness and Haskell memory usage:
miniblog.
Related Posts
I really like the gather macro, abstracting the idea of accumulating a list of results: https://stevelosh.com/blog/2018/05/fun-with-macros-gathering/
I often use `yield` for this in Python, but it gives both laziness and accumulation, so the reader has to work out which you wanted.
Python's yield keyword is rarely useful for laziness. I've only taken advantage of lazy computation a handful of times, e.g. dealing with paginated APIs.
The main advantage is syntactic sugar for producing iterables. Yield is much nicer than appending to a list and returning it!
Creating a circular data structure should be impossible with immutability, right? Amazingly, laziness enables this: