= Memoized successor chain for stateful iterator copies
Represent each generated <sequence> position by an immutable head and a lazily memoized successor, and give each <iterator> its own pointer into the shared chain. Computing a successor invokes the privately owned generator once; lagging copies reuse that same successor. Consequently a mutable <programming closure> generating <Fibonacci numbers> can support interleaved independent cursor positions. Sharing only the generator and a copied current value would instead consume the generator's mutable state twice. This construction can retain all cells between the fastest and slowest live cursors; it does not guarantee constant <memory usage>.
Back to article page