小编F.L*_*lan的帖子

模式不匹配:(_:_:_)

所以我正在尝试构建一个函数,它接受一个元组列表并找到具有最大第二元素的元组.但我得到一个模式匹配错误.

这是我的代码.

    resultTuple :: [((Int,Int),Int)] -> (Int,Int)
    resultTuple [] = error "something wrong"
    resultTuple [x] = fst(x)
    resultTuple (x:y:xs)
        | snd(x) >= snd(y) = resultTuple(x:xs)
        | snd(x) < snd(y) = resultTuple(y:xs)
Run Code Online (Sandbox Code Playgroud)

这是我的错误.

Pattern match(es) are non-exhaustive
In an equation for ‘resultTuple’: Patterns not matched: (_:_:_)
Run Code Online (Sandbox Code Playgroud)

haskell pattern-matching guard-clause

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

标签 统计

guard-clause ×1

haskell ×1

pattern-matching ×1