[Issue 4705] Redesign of std.algorithm.max()/min() + mins()/maxs()
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon May 23 05:17:01 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4705
--- Comment #9 from bearophile_hugs at eml.cc 2011-05-23 05:12:44 PDT ---
Another example, compared to using minPos():
import std.stdio, std.algorithm, std.array;
void main() {
string[] data = ["red", "hello", "yes", "no", "roger", "bud"];
// works in DMD 2.053
string r1 = minPos!q{ walkLength(a) > walkLength(b) }(data).front();
writeln(r1);
// proposed
string r2 = max!q{ walkLength(a) }(items);
writeln(r2);
}
The second version is shorter and more readable, and just like schwartzSort()
the modified max() is more efficient than using minPos when the mapping
function becomes costly to compute.
--
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