[Issue 8590] New: Documentation for "any" and "all" in std.algorithm is incorrect
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Aug 26 09:03:54 PDT 2012
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: nobody at puremagic.com
ReportedBy: Philip.Daniels1971 at gmail.com
--- Comment #0 from Philip Daniels <Philip.Daniels1971 at 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: -------
More information about the Digitalmars-d-bugs
mailing list