std.algorithm.splitter request
pineapple via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jul 18 02:39:13 PDT 2016
On Monday, 18 July 2016 at 09:01:43 UTC, Manu wrote:
> I want a version of splitter that doesn't eat the sentinels.
> I want to split AT the sentinels, but the sentinel should be
> the first
> element of the bucket.
>
> eg: assert(equal(splitter("hello world", ' '), [ "hello", " ",
> " world" ]));
>
> Note the weird behaviour since there are 2 spaces. More useful
> when the data is not strings.
I can't speak to phobos but you should achieve this behavior in
mach.range.split by changing just one line (I'll add some cleaner
support for this myself sometime soon using a template argument,
maybe later today?)
https://github.com/pineapplemachine/mach.d/blob/master/mach/range/split.d
Change line 127 from
this.segmentbegin = this.delimindexes.front +
this.delimlength;
to
this.segmentbegin = this.delimindexes.front;
More information about the Digitalmars-d
mailing list