我试图做一个带有3个参数的函数“ tokenize”。main String,应该在自己的String中的字符字符串,以及要从字符串中删除的chars字符串。
tokenize :: String -> String -> String -> [String]
tokenize [] imp remm = []
tokenize str imp remm = let chr = (head str) in
if elem chr imp then ([chr] : (tokenize (tail str) imp remm))
else if (elem chr remm ) then (tokenize (tail str) imp remm)
else chr: (tokenize (tail str) imp remm)
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息:
Occurs check:
cannot construct the infinite type: a ~ [a]
Expected type: [a]
Actual type: [[a]]
Run Code Online (Sandbox Code Playgroud) haskell ×1