Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
为什么会出现解析错误?我插入一个列表并想要取出元组。(第一行是正确的)。
freq :: Eq a => [a] -> [(Int,a)] freq x:xs = [(x,y)| (x,y) x <- count , y <- rmdups]
这里有两个语法错误——模式上没有括号,并且错误地放在(x,y)了推导式中。它应该是:
(x,y)
freq (x : xs) = [(x, y) | x <- count, y <- rmdups]
您必须在模式匹配中加上括号
freq (x:xs) = {- ... -}