Suggestion: needleless findSplit* methods

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Dec 12 09:41:33 UTC 2017


On Tuesday, December 12, 2017 09:25:57 Seb via Digitalmars-d wrote:
> On Tuesday, 12 December 2017 at 08:19:39 UTC, Piotr Mitana wrote:
> > Hello,
> >
> > I'd like to make a little suggestion for phobos: enrich
> > findSplit* method family with the "needleless" predicate option.
> >
> > [...]
>
> ... or you simply use `until`:
>
>
> auto r = ["23", "42", "14.3", "-323", "}"];
> r.until!(x => !x.isNumeric).map!(to!double).writeln;
>
>
> Runnable example: https://run.dlang.io/is/zNRzpI

You can, but you end up with a different range type that way, whereas with
findSplit*, you can retain the original range type with at least some
ranges. So, improving findSplit* is a perfectly valid enhancement request.
But for some use cases, until will certainly do the job.

- Jonathan M Davis



More information about the Digitalmars-d mailing list