Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-13 Thread Per Nordlöw via Digitalmars-d-learn
On Sunday, 11 October 2015 at 11:17:29 UTC, Nordlöw wrote: Here's a solution: https://github.com/nordlow/justd/blob/f8519e8a1af68bc25cc00c6ef12d13efa791250c/comparison_ex.d Latest version contains a few fixes: https://github.com/nordlow/justd/blob/master/comparison_ex.d

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-12 Thread ixid via Digitalmars-d-learn
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) {

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-11 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 11 October 2015 at 05:06:04 UTC, Nordlöw wrote: On Sunday, 11 October 2015 at 00:16:44 UTC, Meta wrote: 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. With static fo

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-10 Thread Nordlöw via Digitalmars-d-learn
On Sunday, 11 October 2015 at 00:16:44 UTC, Meta wrote: 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. With static foreach in a switch we can do better. I'll put together a sol

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-10 Thread Meta via Digitalmars-d-learn
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) {

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-10 Thread Nordlöw via Digitalmars-d-learn
On Saturday, 10 October 2015 at 16:42:52 UTC, Nordlöw wrote: Found it: http://dlang.org/phobos/std_algorithm_comparison.html#predSwitch An alias would be perhaps be motivated to make newcomers easier grap that this can be used for whole replacements. Ahh, but this doesn't use a hash-table be

Re: Hash-Table-Based Multiple Arguments Replacement

2015-10-10 Thread Nordlöw via Digitalmars-d-learn
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 Found it: http://dlang.org/phobos/std_algorithm_comp

Hash-Table-Based Multiple Arguments Replacement

2015-10-10 Thread Nordlöw via Digitalmars-d-learn
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"; defaul