Lazy generic std.algorithm.replace()
Nordlöw via Digitalmars-d
digitalmars-d at puremagic.com
Fri Oct 23 04:23:54 PDT 2015
Is there a reason why std.algorithm doesn't provide a lazy range
implementation of replace()?
I'm aware this isn't difficult to express using `map` like, for
instance,
auto replace(S, F, T)(S, F from, T to)
{
return s.map!(a => a == from ? to : a);
}
but I prefer syntactic sugars.
While at it we could make use of variadics to enable syntax such
as
assert(equal("do_it".replace('_', ' ',
'd', 'g',
'i', 't',
't', 'o',
"go to");
along with optional predicate (as usual).
What do you say?
More information about the Digitalmars-d
mailing list