On 12/24/2013 12:36 PM, Dfr wrote:
Let's say i have array of kind:

auto a = [["1","0000FF"], ["2", "00FF00"], ...];

Is there simple way to turn it into associative array of kind:

string[string] b = ["1": "0000FF", "2": "00FF00", ...];



void main(){
    import std.array, std.algorithm, std.typecons;
    auto a = [["1","0000FF"], ["2", "00FF00"], /+...+/];
    auto aa = a.map!(x=>tuple(x[0],x[1])).assocArray;

    import std.stdio;
    writeln(aa);
}

Reply via email to