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]));
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).