DEV Community

Discussion on: Daily Challenge #3 - Vowel Counter

Collapse
 
bennypowers profile image
Benny Powers 🇮🇱🇨🇦 • Edited
module Vowels (countVowels) where

import Data.Char (toUpper)

isVowel :: Char -> Bool
isVowel = flip elem "AEIOU"

countChar :: Char -> Integer
countChar letter = if isVowel letter 1 else 0

countVowels :: String -> Integer
countVowels = sum . map (countChar . toUpper)

Will have to double check the syntax (on Mobile) but I think this will work