[Issue 5756] amap() and maybe afilter() too
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Sep 29 15:07:20 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5756
--- Comment #5 from bearophile_hugs at eml.cc 2011-09-29 15:06:38 PDT ---
An example of amap usage. This is input data:
auto data = ["1111100000",
"1111000000",
"1110000000",
"1100001000",
"1000010000",
"0000100001",
"0001000011",
"0010000111",
"0000001111",
"0000011111"];
To convert it into a 2D matrix of booleans:
auto r = array(map!q{ array(map!q{ a == '1' }(a)) }(data));
The result r:
[[true, true, true, true, true, false, false, false, false, false], [true,
true, true, ...]]
Using amap the line of code becomes shorter and less noisy, almost readable:
auto r = amap!q{ amap!q{ a == '1' }(a) }(data);
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list