substitute

Substitute in parallel all elements in r which equal (according to pred) ss[2*n] with ss[2*n + 1] for n = 0, 1, 2, ....

Because ss are known at compile time, time-complexity for each element substitution is O(1).

  1. auto substitute(R r)
    template substitute(ss...)
    substitute
    (
    R
    )
    (
    R r
    )
    if (
    isInputRange!(Unqual!R) &&
    haveCommonType!(ElementType!R, ss)
    )
    if (
    isExpressionTuple!ss &&
    ss.length >= 2
    &&
    )
  2. template substitute(substs...)
  3. auto substitute(R r, Ss ss)
  4. auto substitute(R r, Ss ss)

Members

Functions

substitute
auto substitute(R r)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

assert(`do_it`.substitute!('_', ' ')
			  .equal(`do it`));
int[3] x = [1, 2, 3];
auto y = x[].substitute!(1, 0.1);
assert(y.equal([0.1, 2, 3]));
static assert(is(typeof(y.front) == double));
assert(`do_it`.substitute!('_', ' ',
						   'd', 'g',
						   'i', 't',
						   't', 'o')
			  .equal(`go to`));
import std.range : retro;
assert(equal([1, 2, 3].substitute!(1, 0.1)
					  .retro,
			 [3, 2, 0.1]));

Meta