count until predicate returns false

bearophile bearophileHUGS at lycos.com
Mon Aug 15 15:40:41 PDT 2011


Andrej Mitrovic:

> In the meantime I guess I'll use this monster:
> 
> array(until!(not!isWhite)(line)).length

This is better:

import std.algorithm, std.range, std.ascii, std.functional;

void main() {
    string line = "   foo ";
    size_t n = walkLength(until!(not!isWhite)(line));
    assert(n == 3);
}

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list