On Saturday, 10 October 2015 at 16:19:53 UTC, Nordlöw wrote:
Is there an algorithm somewhere in Phobos which performs when
possible a replacement/substitution based on a variadic
definition of replacements using hash-table search similar to
string replaceWhole(string a)
{
switch (x)
{
case "a": return "1";
case "b": return "2";
default: return x;
}
}
?
Desired interface
y = x.replaceWhole!("a","x",
"b","y",
"c","z")
or perhaps
y = x.replaceWhole!(tuple("a","x"),
tuple("b","y"),
tuple("c","z"))
kind of like
"a".among!("a", "b", "c")
but for replacements.
There was something like this proposed quite awhile ago (can't
remember what it was, might've been extending unary/binaryFun to
accept an AA), but it was rejected.