Count how many vowels and consonants occur in a string: Difference between revisions
Content deleted Content added
→{{header|Python}}: Added a variant selection from the four or more possible meanings of the task definition. |
→{{header|Haskell}}: Updated output in second variant |
||
Line 277: | Line 277: | ||
vowelAndConsonantCounts |
vowelAndConsonantCounts |
||
"Forever Fortran 2018 programming language" |
"Forever Fortran 2018 programming language" |
||
(vTotal, cTotal) = |
|||
⚫ | |||
both |
|||
⚫ | |||
(show . foldr ((+) . snd) 0) |
|||
putStrLn "\nConsonant counts:" |
|||
(v, c) |
|||
⚫ | |||
⚫ | |||
<pre>Vowel counts: |
|||
vTotal |
|||
[('a',4),('e',3),('i',1),('o',3),('u',1)] |
|||
<> " instances of " |
|||
<> show (length v) |
|||
<> " vowels:" |
|||
⚫ | |||
putStrLn [] |
|||
putStrLn $ |
|||
cTotal |
|||
<> " instances of " |
|||
<> show (length c) |
|||
<> " vowels:" |
|||
⚫ | |||
------------------------- GENERIC ------------------------ |
|||
Consonant counts: |
|||
[('F',2),('g',4),('l',1),('m',2),('n',3),('p',1),('r',6),('t',1),('v',1)]</pre> |
|||
both :: (a -> b) -> (a, a) -> (b, b) |
|||
both = join bimap</lang> |
|||
<pre>12 instances of 5 vowels: |
|||
('a',4) |
|||
('e',3) |
|||
('i',1) |
|||
('o',3) |
|||
('u',1) |
|||
21 instances of 9 vowels: |
|||
('F',2) |
|||
('g',4) |
|||
('l',1) |
|||
('m',2) |
|||
('n',3) |
|||
('p',1) |
|||
('r',6) |
|||
('t',1) |
|||
('v',1)</pre> |
|||
=={{header|jq}}== |
=={{header|jq}}== |