DEV Community

Discussion on: Daily Challenge #3 - Vowel Counter

Collapse
 
peterbunting profile image
Peter Bunting

In F#

let isVowel (c:char) =
    match c.ToString().ToLowerInvariant() with
    | "a" | "e" | "i" | "o" | "u" -> 1
    | _ -> 0

let vowelCount (s:string) = s.ToCharArray() |> Array.sumBy(fun x -> isVowel x)

printfn "%d" (vowelCount "The cUnNinG fOx jumpEd over the lazy dog - twice!")