【发布时间】:2012-07-23 14:53:45
【问题描述】:
所以我有这个功能,当我尝试像这样使用它时: 合并排序列表 [1,1] [1,1] 它给了我一个错误:
[1,1*** 例外:SortFunctions.hs:(86,1)-(91,89):非详尽无遗 函数mergeSortedLists中的模式
85 mergeSortedLists :: (Ord t) => [t] -> [t] -> [t]
86 mergeSortedLists [] [] = []
87 mergeSortedLists (x:[]) [] = x:[]
88 mergeSortedLists [] (y:[]) = y:[]
89 mergeSortedLists (x:[]) (y:[]) = (max x y) : (min x y) : []
90 mergeSortedLists (x:tail1) (y:tail2) | x > y = x : (mergeSortedLists tail1 (y:tail2))
91 | otherwise = y : (mergeSortedLists (x:tail1) tail2)
我无法找出问题的根源,因为我认为我涵盖了所有可能的情况。 这里可能是什么问题?
【问题讨论】:
-
您还没有涵盖所有可能的情况。考虑
mergeSortedLists [] [1,1]。 -
@pigworker 确实如此。我太愚蠢。谢谢!