I am trying to write a function score :: Char -> Int that converts a character to its score. Each
letter starts with a score of 1; 1 is added to the score of a character if it is a vowel
(a, e, i, o, u) and 1 is added to the score of a character if it is upper case; a character
that is not a letter scores 0. For example,
score 'A' == 3
score 'a' == 2
score 'B' == 2
score 'b' == 1
score '.' == 0
This is my code so far:
n :: Int -> Int
n = 0
isVowel :: Char -> Char
isVowel x = [if x == 'a' || x == 'e' || x == 'i' ||
x == 'o' || x == 'u' then x else x]
score :: Char -> Int
score x =
[if isAlpha x then n+1 else n ]
[if isUpper x then n+1 else n ]
[if isVowel x then n+1 else n ]
something is definitely wrong with this code, but I cannot find what. Specifically, is there any way to write a function for detecting vowels? I'm not even sure that the one I wrote is correct. Or do I change the type of isVowel to Char -> Bool then if isVowel = True will that work? I will be thankful for any help provided