delegate object instead of a literal

Joel Christensen joelcnz at gmail.com
Mon Aug 15 21:19:53 PDT 2011


On 16-Aug-11 10:22 AM, Jonathan M Davis wrote:
> On Monday, August 15, 2011 14:28 Jonathan M Davis wrote:
>> On Monday, August 15, 2011 02:25 Joel Christensen wrote:
>>> Ok, this is a good one I think.
>>>
>>> import std.string, std.algorithm, std.functional;
>>>
>>> bool isANum( dchar chr ) {
>>> return inPattern( chr, digits ~ `"+-.` );
>>> }
>>>
>>> void main() {
>>> auto input = `abc123`;
>>> auto indexEnd = -1;
>>>
>>> indexEnd = count!( not!isANum )( input );
>>> assert( indexEnd == 3 );
>>> }
>>
>> Actually, it looks like count counts it for the whole range, not just how
>> many before it finds one which doesn't match. So, it's not quite what you
>> were looking for. I misread what it did.
>
> The next release will have a version of countUntil that does what you want
> though.
>
> - Jonathan M Davis

Ok, good. Thanks Jonathan.

- Joel


More information about the Digitalmars-d-learn mailing list