0
belongs :: Eq a => a -> [a] -> [a]
belongs e (h:t) = if (h == e) then [] else belongs e t
belongs e [] = [e]
nub :: Eq a => [a] -> [a]
nub l = nub' l []
where
nub' [] new_list = new_list
nub' (x:xs) new_list = (nub' xs ((\ e new_list ->
case (belongs e new_list) of
[] -> new_list
(h:t) -> (h:new_list))(x new_list)))
无法匹配,期望与实际类型
[a0] -> [a0]
型[a]
在 返回类型的nub'
可能的原因调用的:nub'
应用于 参数太少在表达式:nub' l []
在为nub
的公式:预计冲突和实际参数nub l = nub' l [] where nub' [] new_list = new_list nub' (x : xs) new_list = (nub' xs ((\ e new_list -> case (belongs e new_list) of { [] -> ... (h : t) -> ... }) (x new_list)))
无法比拟预期型
[a0] -> [a0]
与ACTU人型[a1]
在 的nub'
,即[]
在表达式中的第二个参数:nub' l []
在方程nub
:nub l = nub' l [] where nub' [] new_list = new_list nub' (x : xs) new_list = (nub' xs ((\ e new_list -> case (belongs e new_list) of { [] -> ... (h : t) -> ... }) (x new_list)))
为什么它不工作?我不明白。请给我一个手。 错误是可以理解的,但我不知道它们的原因。