On Wednesday, 10 September 2014 at 23:01:44 UTC, Nordlöw wrote:
On Wednesday, 10 September 2014 at 22:45:08 UTC, Nordlöw wrote:
auto byLine(Range)(Range input) if (isForwardRange!Range)
{
   import std.algorithm: splitter;
   import std.ascii: newline;
   static if (newline.length == 1)
   {
       return input.splitter(newline.front);
   }
   else
   {
       return input.splitter(newline);
   }
}

IMHO, this should be added to std.string and restricted to isSomeString. Should I do a PR?

Well, the issue is that this isn't very portable for *reading*, as even on linux, you may read files with "\r\n" line endings (It's "standard" for csv files, for example), or read "\n" terminated files on windows.

The issue is that (currently) we don't have any splitter that operates on multiple needles. *That'd* be what needs to be written (probably not too hard either, since "find" already exists).

We also have splitLines, "http://dlang.org/phobos/std_string.html#.splitLines";. Is that good enough for you by any chance? Or do you need it to actually be lazy?

Reply via email to