digitalmars.D.bugs - [Issue 11111] New: std.algorithm.canFind fails to find in range
- d-bugmail puremagic.com (26/26) Sep 23 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11111
- d-bugmail puremagic.com (11/11) Sep 23 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11111
- d-bugmail puremagic.com (17/17) Sep 23 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11111
- d-bugmail puremagic.com (22/33) Sep 23 2013 http://d.puremagic.com/issues/show_bug.cgi?id=11111
http://d.puremagic.com/issues/show_bug.cgi?id=11111 Summary: std.algorithm.canFind fails to find in range Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nobody puremagic.com ReportedBy: alienballance gmail.com 13:19:17 PDT --- import std.algorithm : canFind; import std.stdio : writeln; void main() { auto r1 = [1,3,4]; auto r2 = [5,2,3,8,0]; writeln(r1.canFind(r2)); // false writeln(r2.canFind(r1)); // false } // DMD 2.063.2 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 23 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11111 Peter Alexander <peter.alexander.au gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |peter.alexander.au gmail.co | |m 13:52:29 PDT --- What's the bug? Neither range contains the other, so canFind returns false. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 23 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11111 Mariusz GliwiĆski <alienballance gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID 14:43:30 PDT --- I'm sorry for reporting false bug-report then. size_t canFind(alias pred = "a == b", Range, Ranges...)(Range haystack, Ranges needles); It's "Ranges" and not "Range" as i've seen, and: "if used directly in the condition of an if statement or loop, the result will be true if one of the needles is found and false if none are found" just looked like "find the first index of needle from Range of needles". -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 23 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11111 monarchdodra gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED CC| |monarchdodra gmail.com Resolution|INVALID | Summary|std.algorithm.canFind fails |std.algorithm.canFind |to find in range |should support Needles...I'm sorry for reporting false bug-report then. size_t canFind(alias pred = "a == b", Range, Ranges...)(Range haystack, Ranges needles); It's "Ranges" and not "Range" as i've seen, and: "if used directly in the condition of an if statement or loop, the result will be true if one of the needles is found and false if none are found" just looked like "find the first index of needle from Range of needles".I think it's worth noting that "Ranges..." is a gratuitious limitation, as the function would perfectly support "Needles". EG: If you unlock the restraint, than this work for me: assert([1, 2, 3].canFind(5, [1, 2, 3], 2) == 3); I renamed the bug report, it should be fixed. -------- In your original use case though, I don't think we have any version of find that accepts a variable amount of needles (which is what you were asking for?). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 23 2013