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

           Summary: Documentation for "any" and "all" in std.algorithm is
                    incorrect
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: philip.daniels1...@gmail.com


--- Comment #0 from Philip Daniels <philip.daniels1...@gmail.com> 2012-08-26 
09:03:45 PDT ---
Any: "Performs Ο(r.length) evaluations of pred."

This is incorrect, the function returns as soon as it finds an item matching
pred.



All: "Performs Ο(r.length) evaluations of pred."

This is incorrect, the function returns as soon as it finds an item that does
not match pred.


Both cases should be obvious from an examination of the code in std.algorithm,
but here is a proof case anyway:


bool pred(int x)
{
    writeln("running pred");
    return x == 3;
}

void test_any()
{
    writeln("Testing any");
    int[] x = [1, 2, 3, 4, 5];
    auto a = any!(pred)(x);
}

void test_all()
{
    writeln("Testing all");
    int[] x = [1, 2, 3, 4, 5];
    auto a = all!(pred)(x);
}

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

Reply via email to