Count how many vowels and consonants occur in a string: Difference between revisions
Content deleted Content added
No edit summary |
Add Factor |
||
Line 4: | Line 4: | ||
<br><br> |
<br><br> |
||
=={{header|Factor}}== |
|||
{{works with|Factor|0.99 2021-06-02}} |
|||
<lang factor>USING: ascii combinators io kernel math.statistics prettyprint |
|||
sequences ; |
|||
CONSTANT: vowels "aeiouAEIOU" |
|||
: letter-type ( char -- str ) |
|||
{ |
|||
{ [ dup vowels member? ] [ drop "vowel" ] } |
|||
{ [ Letter? ] [ "consonant" ] } |
|||
[ "other" ] |
|||
} cond ; |
|||
"Forever Factor programming language" |
|||
"Now is the time for all good men to come to the aid of their country." |
|||
[ dup ... " -> " write [ letter-type ] histogram-by . nl ] bi@</lang> |
|||
{{out}} |
|||
<pre> |
|||
"Forever Factor programming language" |
|||
-> H{ { "other" 3 } { "consonant" 20 } { "vowel" 12 } } |
|||
"Now is the time for all good men to come to the aid of their country." |
|||
-> H{ { "other" 16 } { "consonant" 31 } { "vowel" 22 } } |
|||
</pre> |
|||
=={{header|Go}}== |
=={{header|Go}}== |