counting characters

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jul 19 06:37:33 PDT 2016


On 7/19/16 8:23 AM, celavek wrote:
> On Tuesday, 19 July 2016 at 09:57:27 UTC, Lodovico Giaretta wrote:
>> On Tuesday, 19 July 2016 at 09:42:40 UTC, celavek wrote:
>>
>> Works for me:
>>
>> size_t[char] counts;
>> const string dna_chain =
>> "AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC";
>> counts['A'] = countchars(dna_chain, "A");
>
> It was failing for me as I was using "countchars!". I thought that I
> should use the "!" in order to instantiate a template in D. I'm still
> confused why it is working without the "!". Anyway the compiler message
> was not very helpful.

https://dlang.org/spec/template.html#function-templates

Check out the section a little bit down that talks about implicitly 
deduced template parameters.

-Steve


More information about the Digitalmars-d-learn mailing list