View source code
Display the source code in std/algorithm/iteration.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.algorithm.iteration.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).
auto auto joiner(RoR, Separator)
(
RoR r,
Separator sep
)
if (isInputRange!RoR && isInputRange!(ElementType!RoR) && isForwardRange!Separator && is(ElementType!Separator : ElementType!(ElementType!RoR)));
auto auto joiner(RoR)
(
RoR r
)
if (isInputRange!RoR && isInputRange!(ElementType!RoR));
Parameters
Name | Description |
---|---|
r | An input range of input ranges to be joined. |
sep | A forward range of element(s) to serve as separators in the joined range. |
Returns
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.
See also
std
, which chains a sequence of ranges with compatible elements
into a single range.
Example
import std .algorithm .comparison : equal;
import std .conv : text;
assert(["abc", "def"] .joiner .equal("abcdef"));
assert(["Mary", "has", "a", "little", "lamb"]
.joiner("...")
.equal("Mary...has...a...little...lamb"));
assert(["", "abc"] .joiner("xyz") .equal("xyzabc"));
assert([""] .joiner("xyz") .equal(""));
assert(["", ""] .joiner("xyz") .equal("xyz"));
Authors
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.