Hash-Table-Based Multiple Arguments Replacement
ixid via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Oct 12 06:31:33 PDT 2015
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.
It would also be nice to have a splitter that can split on any of
a number of conditions being fulfilled in a similar vein.
More information about the Digitalmars-d-learn
mailing list