repeat

Create a range which repeats one value.

  1. Repeat!T repeat(T value)
    repeat
    (
    T
    )
    ()
  2. Take!(Repeat!T) repeat(T value, size_t n)

Parameters

value T

the value to repeat

Return Value

Type: Repeat!T

If n is not defined, an infinite random access range with slicing.

If n is defined, a random access range with slicing.

Examples

import std.algorithm.comparison : equal;

assert(5.repeat().take(4).equal([5, 5, 5, 5]));
import std.algorithm.comparison : equal;

assert(5.repeat(4).equal([5, 5, 5, 5]));

Meta