1 assert(`do_it`.substitute!('_', ' ') 2 .equal(`do it`)); 3 int[3] x = [1, 2, 3]; 4 auto y = x[].substitute!(1, 0.1); 5 assert(y.equal([0.1, 2, 3])); 6 static assert(is(typeof(y.front) == double)); 7 assert(`do_it`.substitute!('_', ' ', 8 'd', 'g', 9 'i', 't', 10 't', 'o') 11 .equal(`go to`)); 12 import std.range : retro; 13 assert(equal([1, 2, 3].substitute!(1, 0.1) 14 .retro, 15 [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).