[Issue 11111] std.algorithm.canFind should support Needles...

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Sep 23 23:30:27 PDT 2013


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


monarchdodra at gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |monarchdodra at gmail.com
         Resolution|INVALID                     |
            Summary|std.algorithm.canFind fails |std.algorithm.canFind
                   |to find in range            |should support Needles...


--- Comment #3 from monarchdodra at 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: -------


More information about the Digitalmars-d-bugs mailing list