小编Rai*_*ain的帖子

我在 Haskell 中解决递归问题后出现警告

我正在尝试实现下面的代码问题,但我收到了此类警告。我不知道发生了什么,因为我可以正确输出答案。下面是我的代码和警告:

continuous :: [Integer] -> Bool
continuous list = case list of 
            [] -> True
            [x,y] 
                 | abs (x-y) <= 1 -> True 
                 | otherwise -> False
            x:y:xs 
                | abs(x-y) <= 1 -> continuous (y:xs)
                | otherwise -> False 
Lists.hs:43:19: warning: [-Wincomplete-patterns]
Pattern match(es) are non-exhaustive
In a case alternative: Patterns not matched: [_]
   |
43 | continuous list = case list of 
   |                   ^^^^^^^^^^^^^...
Run Code Online (Sandbox Code Playgroud)

recursion haskell list

0
推荐指数
1
解决办法
63
查看次数

标签 统计

haskell ×1

list ×1

recursion ×1