如何在Haskell中编写排除某个输入参数的案例

问题描述 投票:0回答:1

在 Haskell 中我该怎么写:

function :: (Int,Int) ....
function Not(0,0) otherparameters = []

即我有一个函数,除了第一个参数是元组 (0,0) 之外,我想为每种情况返回一个空列表

如何在 Haskell 中做到这一点?

我尝试过函数(不是(0,0))但收到以下错误

Parse error in pattern: not

非常感谢

haskell parameters functional-programming tuples
1个回答
0
投票

先写异常模式:

function :: (Int,Int) ....
function (0,0) otherParameters = exceptionalResult
function _     _               = [] -- empty list in every other case
© www.soinside.com 2019 - 2024. All rights reserved.