D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2903 - Splitter should be bi-dir if the input range is bi-dir
Summary: Splitter should be bi-dir if the input range is bi-dir
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 enhancement
Assignee: Andrei Alexandrescu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-26 21:30 UTC by Brad Roberts
Modified: 2015-06-09 01:26 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Brad Roberts 2009-04-26 21:30:54 UTC
obviously there's 'better' ways of doing this, but use it an a contrived example:

    string inputpath = "/a/b";

    auto parts = splitter(inputpath, "/");
    // parts is ["", "a", "b"]
    parts.popFront; // get rid of empty leading part
    auto file = parts.back;
    parts.popBack;
    writefln("file = %s", file);
    auto path = reduce!(q{a ~= "/" ~ b})("", parts);
    writefln("path = %s", path);

Problem: Splitter is strictly a forward range currently.
Comment 1 David Simcha 2010-08-17 21:07:53 UTC
Fixed SVN.