digitalmars.D - std.algorithm.splitter request
- Manu via Digitalmars-d (6/6) Jul 18 2016 I want a version of splitter that doesn't eat the sentinels.
- pineapple (11/19) Jul 18 2016 I can't speak to phobos but you should achieve this behavior in
- pineapple (3/7) Jul 18 2016 Can't push at the moment but here you go
- pineapple (3/5) Jul 18 2016 "hello world".split!(true, false)(' ') will enumerate ["hello",
- Jack Stouffer (4/11) Jul 18 2016 I recently added this feature to std.regex.splitter:
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.
Jul 18 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;
Jul 18 2016
On Monday, 18 July 2016 at 09:39:13 UTC, pineapple wrote: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?)Can't push at the moment but here you go http://pastebin.com/f2TxDg8F
Jul 18 2016
On Monday, 18 July 2016 at 09:52:25 UTC, pineapple wrote:Can't push at the moment but here you go http://pastebin.com/f2TxDg8F"hello world".split!(true, false)(' ') will enumerate ["hello", " ", " world"].
Jul 18 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 recently added this feature to std.regex.splitter:
https://github.com/dlang/phobos/pull/4174
Should be in the nightlies.
Jul 18 2016









pineapple <meapineapple gmail.com> 