在下面的代码中,Haskell抱怨
Non-exhaustive patterns in function prime'
prime :: Int -> [Int]
prime x = prime' [2..x] where
prime' (p:ps)= p : prime' [x | x <- ps, mod x p > 0 && prime'' x [2..div x 2]]
prime'' _ [] = True
prime'' n (x:xs)
| mod n x == 0 = False
| otherwise = prime'' n xs
prime' []=[]
Run Code Online (Sandbox Code Playgroud)
我找不到我的错误.有人可以解释为什么会发生这种情况,这意味着什么?
我应该在Haskell中编写一个小函数,它应该擦除列表中两次的元素.不幸的是,Haskell抱怨"输入错误'|'' ".有人可以帮我吗?
makeSets=mSet[]s
where
mSet stack []=stack
mSet stack (x:xs)
|contains stack x=mSetstack xs
| otherwise =mSet (x:stack) xs
where
contains [] thing=False
contains (x:xs)thing
| x==thing=True
|otherwise=contains xs thing
Run Code Online (Sandbox Code Playgroud)