为什么会出现解析错误?我插入一个列表,并希望得到元组.(顶行是正确的).
freq :: Eq a => [a] -> [(Int,a)]
freq x:xs = [(x,y)| (x,y) x <- count , y <- rmdups]
Run Code Online (Sandbox Code Playgroud)
这里有两个语法错误 - 模式上没有括号,错误地放在(x,y)理解中.它应该是:
freq (x : xs) = [(x, y) | x <- count, y <- rmdups]
Run Code Online (Sandbox Code Playgroud)