插入功能提供非详尽的模式

Raf*_*tro -1 haskell

我正在尝试插入两个这样的列表:

intercalate [0, 2, 4] [1, 3, 5]
[0, 1, 2, 3, 4, 5]
Run Code Online (Sandbox Code Playgroud)

所以我创建了这个函数:

intercalate (x:xs) (y:ys) = x:(y:(intercalate xs ys))
intercalate [] [] = []
Run Code Online (Sandbox Code Playgroud)

但是我总是得到这个错误:

 Exception: <interactive>:3:5-57: Non-exhaustive patterns in function intercalate
Run Code Online (Sandbox Code Playgroud)

我不明白为什么!

chi*_*chi 6

这里的提示应该足够了:

您处理两个列表都为空的情况.

您处理两个列表都非空的情况.

你能再考虑两个案例吗?