Count how many vowels and consonants occur in a string: Difference between revisions

Content deleted Content added
PureFox (talk | contribs)
Added Go
Thundergnat (talk | contribs)
→‎{{header|Raku}}: Add a Raku example
Line 46: Line 46:
contains 22 vowels and 31 consonants.
contains 22 vowels and 31 consonants.
</pre>
</pre>

=={{header|Raku}}==
Note that the task '''does not''' ask for the '''total count''' of vowels and consonants, but for '''how many''' occur.

<lang perl6>my @vowels = <a e i o u>;
my @consonants = <b c d f g h j k l m n p q r s t v w x y z>;

sub letter-check ($string) {
my $letters = $string.lc.comb.Set;
"{sum $letters{@vowels}} vowels and {sum $letters{@consonants}} consonants occur in the string \"$string\"";
}

say letter-check "Forever Ring Programming Language";</lang>

{{out}}
<pre>5 vowels and 8 consonants occur in the string "Forever Ring Programming Language"</pre>



=={{header|Ring}}==
=={{header|Ring}}==
{{incorrect|Ring|[, ], \, _, and ` are not consonants}}
<lang ring>
<lang ring>
load "stdlib.ring"
load "stdlib.ring"