http://d.puremagic.com/issues/show_bug.cgi?id=4705



--- Comment #12 from bearophile_h...@eml.cc 2011-09-14 15:51:52 PDT ---
Another use case. Given this struct:

struct Foo {
    double x;
    int[100] a;
}


This D code finds the struct with the smallest x and assigns it to good[index]:

size_t idmin = 0;
foreach (size_t i; 1 .. N)
    if (foos[i].x < foos[idmin].x)
        idmin = i;
good[index] = foos[idmin];


With the improvement I have proposed you are allowed to replace it with a
higher level code, that expresses the  idea clearly, is less bug-prone, and
reqires one 1 instead of 5:


good[index] = min!q{ a.x }(foos);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to