Splitting Ranges using Lambda Predicates

monarch_dodra via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 10 14:26:49 PDT 2014


On Tuesday, 10 June 2014 at 21:11:17 UTC, Nordlöw wrote:
>> 1. someName => SomeName
>
> My example is dumb and incorrect.
>
> I actually want this to do the following
>
> 2. "_someGreatVariableName" => "Some Great Varible Name"

The current splitter works on the notion of splitter "tokens", 
eg, it splits when it find an element or range that corresponds 
to the passed value/pred.

What exactly are you requesting though?
- Split on the "edge" lowercase to uppercase?
- Split on uppercase but keep the uppercase element?

Either way, your example should look like this:

"SomeGreatVariableName" => ["Some", "Great", "Variable", "Name"]

Since you are splitting up your range into subranges.

And also either way, AFAIK, yeah, we don't have any splitter that 
does that. We are also missing the version that takes both a 
range an predicate, which would allow things like:

"This Cool thing is COOL!!!".split((a, b)=>a == 
b.toLower())("cool")
   =>
["This ", " thing is ", "!!!"]

Looks like you'll have to roll your own :/


More information about the Digitalmars-d-learn mailing list