The OpenD Programming Language

repeat

Create a range which repeats one value.

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

Parameters

value T

the value to repeat

n size_t

the number of times to repeat value

Return Value

Type: Take!(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(4).equal([5, 5, 5, 5]));
import std.algorithm.comparison : equal;

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

Meta