The OpenD Programming Language

cycle

Cycle repeates 1-dimensional field/range/array/slice in a fixed length 1-dimensional slice.

Examples

auto slice = iota(3);
assert(slice.cycle(7) == [0, 1, 2, 0, 1, 2, 0]);
assert(slice.cycle!2(7) == [0, 1, 0, 1, 0, 1, 0]);
assert([0, 1, 2].cycle(7) == [0, 1, 2, 0, 1, 2, 0]);
assert([4, 3, 2, 1].cycle!4(7) == [4, 3, 2, 1, 4, 3, 2]);

Meta