-- Count the number of vowels in each line module Main where import Data.Char as Char {- takeWhile :: (a -> Bool) -> [a] -> [a] ; longest prefix satisfying predicate -} main :: IO() main = interact (unlines . (map (show . count)) . (takeWhile (notStart '*')) . lines) vowel :: Char -> Bool vowel x = (Char.toUpper x) `elem` "AEIOU" notStart :: Char -> String -> Bool notStart c line = c /= (head line) notStartStar :: String -> Bool notStartStar = ('*' /=).head count :: String -> Int count = foldr (\x c ->if vowel x then c+1 else c) 0 -- ------------For GNU Emacs ------------ -- Local Variables: -- compile-command: "ghc -Wall count.hs" -- End: