chickadee » srfi-121 » gindex

gindex value-gen index-genprocedure

Creates a generator that returns elements of value-gen specified by the indices (non-negative exact integers) generated by index-gen. It is an error if the indices are not strictly increasing, or if any index exceeds the number of elements generated by value-gen. The result generator is exhausted when either generator is exhausted, at which time the other is in an undefined state.

(generator->list (gindex (list->generator '(a b c d e f))
                         (list->generator '(0 2 4))))
 ⇒ (a c e)