Hello,

I'd like to make a little suggestion for phobos: enrich findSplit* method family with the "needleless" predicate option.

Motivation:

Let's have a range of string tokens that - after cutting of the initial brace - looks like this:

    auto range = ["23", "42", "14.3", "-323", "}"]

Now I want to map all the numbers to the array:

auto array = range.findSplitBefore(x => !x.isNumeric).map(to!double).array;

As you can see, I do not need the second parameter of prediate, as I am not comparing the subsequent haystack elements with any needle - I check the condition on the haystack elements alone instead. Unfortunately, It's not that simple, because I have only this prototype:

auto findSplitBefore(alias pred, R1, R2)(R1 haystack, R2 needle) //[...]

That's why I need to add a dummy parameter to achieve what I want to:

auto array = range.findSplitBefore(x => !x.isNumeric)([""]).map(to!double).array;

So I suggest adding this prototype as well for convenience:

     auto findSplitBefore(alias pred, R)(R haystack) //[...]

Reply via email to