I'm doing an exercise where I need to make a function called, allLow that has the signature of allLow :: String -> String
that takes a String and prints out all the capital letters, recursively. So it will run like,
> allLow "WhERe IS MY PEPPErONI PIZZa?"
"hera"
Here's what I have:
allLow :: String -> String
allLow "" = ""
allLow (c:cs) = if lowerCase c = True then (c ++ (allLow cs))
I wrote a function called, "lowerCase" (Char -> Bool) which returns true if the given char is lowercase. I am assuming that I can test lowerCase's validity at each "index" of the string and pump out all uppercase letters that way, but it's not working. The error message isn't helping me. It's saying there is a parse error at '=' but Idk what that means. It's not supposed to be == True.
if upperCase c
==True
. Why isn't it supposed to be ==? Also, what if c isn't uppercase? Where's the else condition? – shree.pat18==
is always for equality anywhere AFAIK, as long as the type is an instance ofEq
. – shree.pat18== True
, it's redundant. You can simply writeif upperCase c then ... else ...
. Even in English, "if it is true that c is upper case, then .." is more distracting than the direct "if c is upper case, then ....". – chi