Need help with basic functional programming
bearophile via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 22 10:09:28 PDT 2014
Eric:
> while (!buf.empty())
> {
> p++;
> buf.popFront();
Those () can be omitted, if you mind the noise (but you can also
keep them).
> if (buf.front() <= '0' || buf.front() >= '9') break;
std.ascii.isDigit helps.
> curTok.image = cast(string) cbuffer[0 .. (p -
> cbuffer.ptr)].dup;
If you want a string, then idup is better. Try to minimize the
number of casts in your code.
> auto s = buf.until("a <= '0' || a >= '9'");
Perhaps you need a ! after the until, or a !q{a <= '0' || a >=
'9'}.
> Also, what is the fastest way to convert a range to a string?
The "text" function is the simplest.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list