std.algorithm.startsWith only predicate
Meta via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Oct 18 10:58:29 PDT 2015
On Sunday, 18 October 2015 at 17:48:20 UTC, Freddy wrote:
> How do you call startsWith with only a predicate
> ---
> import std.algorithm;
> import std.ascii;
>
> bool iden(string str)
> {
> return str.startsWith!(a => a.isAlpha || a == '_');
> }
> ---
Is this a simplified use case of some actual code you have?
Otherwise, you can just do:
bool iden(string str)
{
auto f = str.front;
return f.isAlpha || f == '_';
}
More information about the Digitalmars-d-learn
mailing list