Iterator which yields an infinite repetition of given input iterable's values. Produces no values if input is empty. If num is given, only that many cycles will be emitted.
input
num
Also see repeat, repeatedly for related functions.
// take 5 from infinite sequence [...take(5, cycle([1, 2, 3]))] // [1, 2, 3, 1, 2] // only produce 2 cycles [...cycle(range(3), 2)] // [ 0, 1, 2, 0, 1, 2 ]
-
Generated using TypeDoc
Iterator which yields an infinite repetition of given
input
iterable's values. Produces no values ifinput
is empty. Ifnum
is given, only that many cycles will be emitted.Also see repeat, repeatedly for related functions.
// take 5 from infinite sequence [...take(5, cycle([1, 2, 3]))] // [1, 2, 3, 1, 2] // only produce 2 cycles [...cycle(range(3), 2)] // [ 0, 1, 2, 0, 1, 2 ]