www.digitalmars.com         C & C++   DMDScript  

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


           Summary: findSplitBefore/After should have needle-less
           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

--- Comment #0 from Jakob Ovrum <jakobovrum 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:

    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