www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10933] New: findSplitBefore/After should have needle-less overloads

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

           Summary: findSplitBefore/After should have needle-less
                    overloads
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: jakobovrum gmail.com



---
`find` has an overload that doesn't take a needle but requires an unary
predicate function. `findSplitBefore` and `findSplitAfter` should have
equivalent overloads.

Test illustrating use:

----
unittest
{
    import std.algorithm : findSplitBefore;
    import std.uni : isWhite;
    import std.string : stripLeft;

    immutable tests = [
        "prefix postfix lorem ipsum",
        "prefix\tpostfix lorem ipsum"
    ];

    foreach(test; tests)
    {
        auto result = test.findSplitBefore!isWhite();
        assert(result[0] == "prefix");
        assert(result[1].stripLeft() == "postfix lorem ipsum");
    }
}
----

It would be especially useful because `until` is strictly lazy and thus can't
be used with slicing to reproduce the above results.

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