range simple toy problem

Xiaoxi xiaoxi at 163.com
Fri Jun 1 17:00:45 UTC 2018


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.

Thanks,
The Range n00b



More information about the Digitalmars-d-learn mailing list