如何检查 bool 列表是否包含 True?
例如
[True,False] = True
[False,False] = False
[False,False,True] = True
最佳答案
您始终可以检查 Hoogle 中是否存在标准函数。
例如:http://www.haskell.org/hoogle/?hoogle=%5BBool%5D+-%3E+Bool
给你几个函数,其中 或
是满足这个要求的。
编辑:
或
是一个函数。它的签名 或::[Bool] -> Bool
意味着它接收 Bool
列表并返回 Bool
。
所以,只是做
myList = [True, False, False]
if (or myList) then ..something.. else ..something else..
可能是您将如何在代码中使用它(用实际表达式替换 ..something.. 和 ..something else..)。
关于haskell - 如何检查 bool 列表是否包含值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19227191/