Hm, lost p6l along the way. Forwarding.

---------- Forwarded message ----------
From: Carl Mäsak <cma...@gmail.com>
Date: Wed, Jan 27, 2010 at 2:31 PM
Subject: Re: Counting characters
To: Moritz Lenz <mor...@faui2k3.org>


Moritz (>), Carl (>>):
>> How is "character counting" done in Perl 6?
>>
>> In Perl 5, it is `scalar tr/CG//` if I want to count the number of Cs
>> plus the number of Gs in a string.
>
> +$str.comb(/<[GC]>/)
>
> Probably not as efficient as in Perl 5, though

Heh, the thought about .comb seemed to occur to a lot of people
(including me) at the same time. Thanks. :)

Recognizing a lone character class inside a literal regex in a comb
call whose result gets immediately numified sounds to me like an
excellent use case for a sufficiently cunning optimizer. :)

// Carl

Reply via email to