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

m
Line 249:
import Data.Bifunctor (bimap)
import Data.Char (isAlpha)
import Data.List (intercalate, partition)
import qualified Data.Map.Strict as M
 
Line 271:
 
isVowel :: Char -> Bool
isVowel c = c (`elem` "aeiouAEIOU")
 
--------------------------- TEST -------------------------
Line 291:
<> fmap
('\t' :)
( [ show vTotalconcatMap
<> " characters drawn from "report
[ ("vowels", <> show (lengthvTotal, v),
<> (" vowels:consonants", cTotal, c)
]
<> (('\t' :) . show <$> v)
<> [ "",
show cTotal <> " characters drawn from "
<> show (length c)
<> " consonants:"
]
<> (('\t' :) . show <$> c)
)
 
------------------------ FORMATTING ----------------------
 
report :: (String, Int, [(Char, Int)]) -> [String]
report (label, total, xs) =
[ show total
show cTotal <> ( " characters drawn from "
<> show (length cxs)
<> (' ' : ]label)
<> [ ":",
)
]
<> (('\t' :) . show <$> vxs)
<> [""]
 
------------------------- GENERIC ------------------------
9,655

edits