The OpenD Programming Language

fill

Assigns value to each element of input range range.

Alternatively, instead of using a single value to fill the range, a filler forward range can be provided. The length of filler and range do not need to match, but filler must not be empty.

  1. void fill(Range range, Value value)
  2. void fill(InputRange range, ForwardRange filler)
    void
    fill
    (
    InputRange
    ForwardRange
    )
    (
    InputRange range
    ,
    ForwardRange filler
    )
    if (
    isInputRange!InputRange &&
    (
    isForwardRange!ForwardRange ||
    (
    isInputRange!ForwardRange &&
    isInfinite!ForwardRange
    )
    )
    &&
    is(typeof(InputRange.init.front = ForwardRange.init.front))
    )

Parameters

range InputRange

An input range that exposes references to its elements and has assignable elements

filler ForwardRange

A forward range representing the fill pattern.

Throws

If filler is empty.

Examples

int[] a = [ 1, 2, 3, 4, 5 ];
int[] b = [ 8, 9 ];
fill(a, b);
assert(a == [ 8, 9, 8, 9, 8 ]);
int[] a = [ 1, 2, 3, 4 ];
fill(a, 5);
assert(a == [ 5, 5, 5, 5 ]);

See Also

Meta