I'm new at learning Haskell so I'll say sorry in advance for the silly questions.
I want to build a function that removes all the upper cases from a string (I use GHCI)
removeUppercase st = [c| c<-st, c 'elem' ['A..'Z']]
But when I compile it, it shows the following message:
Syntax error on 'elem'
Perhaps you intended to use TemplateHaskell
In the Template Haskell quotation 'elem'
What am I doing wrong?
You used an apostrophe '
, where you should have used a backtick `
. Also, you're missing a closing single quote:
removeUppercase st = [c | c <- st, c `elem` ['A' .. 'Z']]
Note that your function is the same as
removeUppercase = filter (`elem` ['A' .. 'Z'])
This answer is a community answer since the actual question doesn't seem on-topic for StackOverflow, as the error origins from a typographical mistake.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.