[Issue 10933] New: findSplitBefore/After should have needle-less overloads

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 30 23:26:47 PDT 2013


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 at puremagic.com
        ReportedBy: jakobovrum at gmail.com


--- Comment #0 from Jakob Ovrum <jakobovrum at gmail.com> 2013-08-30 23:26:46 PDT ---
`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: -------


More information about the Digitalmars-d-bugs mailing list