delegate object instead of a literal

Jonathan M Davis jmdavisProg at gmx.com
Mon Aug 15 14:28:29 PDT 2011


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.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list