chickadee » srfi-121 » gdrop

gtake gen k #!optional paddingprocedure
gdrop gen kprocedure

These are generator analogues of SRFI 1 take and drop. gtake returns a generator that yields (at most) the first k items of the source generator, while gdrop returns a generator that skips the first k items of the source generator.

These won't complain if the source generator is exhausted before generating k items. By default, the generator returned by gtake terminates when the source generator does, but if you provide the padding argument, then the returned generator will yield exactly k items, using the padding value as needed to provide sufficient additional values.