Wraps a generator to retain its state for a specified number of return operations.
This is useful when you want to keep a generator alive through operations that would
normally terminate it.
A wrapped generator that retains state for the specified count of return operations
Example
// Useful in composition when you need to preserve generator state constgen = G.retain(myGenerator, 2); // gen will survive 2 return() calls before terminating
Wraps a generator to retain its state for a specified number of return operations. This is useful when you want to keep a generator alive through operations that would normally terminate it.