Philippe Sigaud:

    auto a = [["1","0000FF"], ["2", "00FF00"]];
    import std.algorithm: reduce;
   string[string] b;
b = reduce!((aa, pair) { aa[pair[0]] = pair[1]; return aa;})(b,a);
    writeln(b);

While this code seems correct (and I think it's kind of common in Scala), I consider it an obfuscation to avoid. A normal foreach loop is much more readable and should be preferred for this. Functional-style programming is not always the best.

Bye,
bearophile

Reply via email to