http://d.puremagic.com/issues/show_bug.cgi?id=8715
bearophile_h...@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|zipWith |map, filter, zip with | |functional | |arrays/associative arrays --- Comment #5 from bearophile_h...@eml.cc 2012-12-13 02:53:58 PST --- Another example: import std.stdio: writeln; import std.algorithm: map, filter; void main() { int[] data = [0, 1, 2, 3]; bool[] mask = [true, false, true, false]; int[int] conv = [0:10, 1:20, 2:30, 3:40]; auto r1 = data .filter!(i => mask[i])() .map!(i => conv[i])(); writeln(r1); // Prints: [10, 30] } This is nicer: import std.stdio: writeln; import std.algorithm: map, filter; void main() { int[] data = [0, 1, 2, 3]; bool[] mask = [true, false, true, false]; int[int] conv = [0:10, 1:20, 2:30, 3:40]; auto r2 = data.filter!mask().map!conv(); writeln(r2); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------