On Tue, Dec 24, 2013 at 12:36 PM, Dfr <defle...@yandex.ru> 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", ...];
To build a value (your b) from a range (a), you can use std.algorithm.reduce, it's a very generic algo: 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);