功能说明:
编写一个函数any_zeroes : int list -> bool
,如果输入列表中至少包含一个0
,则返回true。
代码:
let any_zeroes l: int list =
List.exists 0 l
错误:
This expression has type int but an expression was expected of type
'a -> bool
我不知道为什么当我将“l”标记为“int list”时,Ocaml会在“0”处出现问题。如果有人能帮我解决这个问题,我将非常感激!谢谢!
List.mem
。 - Anton Trunov