On 6/1/18 1:00 PM, Xiaoxi wrote:
import std.range;
import std.algorithm;
import std.string;
import std.stdio;

void main()
{
   auto s = "1 2 3 4 5 6 7 8 9";
   auto iter = s.split(" ").drop(2);

   // How to find the unconsumed/not-split part of s here?
   // i.e. "3 4 5 6 7 8 9" NOT ["3", "4", "5", "6", "7", "8", "9"]
   // s[??? .. $] <- what goes here?
}

split is just an example, it's a generic question if you chain multiple lazy functions and then consume a part of the data... how do you know how to slice the original buffer to point to the unconsumed data? Imagine the chain could be quite long

s.one.two.three.four.five.six.seven()

You don't really want to lazily add the inverse of all the functions and they might even be destructive so it might not be possible in all cases.

Yes, this is a problem in range-land that is difficult to solve.

I don't know of a good answer to it. Probably you want to use algorithms instead of range wrappers to do this, but I don't know how to do this one-liner style.

I found ranges/algorithms substandard when trying to get the *other* data instead (i.e. what if you wanted "1 2" instead).

-Steve

Reply via email to