Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
September 23, 2013 [Issue 11111] New: std.algorithm.canFind fails to find in range | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from Mariusz Gliwiński <alienballance@gmail.com> 2013-09-23 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: ------- |
September 23, 2013 [Issue 11111] std.algorithm.canFind fails to find in range | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mariusz Gliwiński | 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 --- Comment #1 from Peter Alexander <peter.alexander.au@gmail.com> 2013-09-23 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: ------- |
September 23, 2013 [Issue 11111] std.algorithm.canFind fails to find in range | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mariusz Gliwiński | 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 --- Comment #2 from Mariusz Gliwiński <alienballance@gmail.com> 2013-09-23 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: ------- |
September 24, 2013 [Issue 11111] std.algorithm.canFind should support Needles... | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mariusz Gliwiński | 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... --- Comment #3 from monarchdodra@gmail.com 2013-09-23 23:30:25 PDT --- (In reply to comment #2) > 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: ------- |
Copyright © 1999-2021 by the D Language Foundation