joiner

Lazily joins a range of ranges with a separator. The separator itself is a range. If a separator is not provided, then the ranges are joined directly without anything in between them (often called flatten in other languages).

  1. auto joiner(RoR r, Separator sep)
  2. auto joiner(RoR r)
    joiner
    (
    RoR
    )
    (
    RoR r
    )
    if (
    isInputRange!RoR &&
    isInputRange!(ElementType!RoR)
    )

Parameters

r
Type: RoR

An input range of input ranges to be joined.

Return Value

Type: auto

A range of elements in the joined range. This will be a forward range if both outer and inner ranges of RoR are forward ranges; otherwise it will be only an input range.

Examples

1 import std.algorithm.comparison : equal;
2 import std.conv : text;
3 
4 assert(["abc", "def"].joiner.equal("abcdef"));
5 assert(["Mary", "has", "a", "little", "lamb"]
6     .joiner("...")
7     .equal("Mary...has...a...little...lamb"));
8 assert(["", "abc"].joiner("xyz").equal("xyzabc"));
9 assert([""].joiner("xyz").equal(""));
10 assert(["", ""].joiner("xyz").equal("xyz"));

See Also

std.range.chain, which chains a sequence of ranges with compatible elements into a single range.

Meta