我有一个基本函数,它检查列表中是否有重复项,如果发现它们则返回true,否则返回false。Ocaml - 在列表中检查重复项时的参数类型
# let rec check_dup l = match l with
[] -> false
| (h::t) ->
let x = (List.filter h t) in
if (x == []) then
check_dup t
else
true
;;
然而,当我尝试使用此代码,我得到的错误
Characters 92-93:
let x = (List.filter h t) in
^
Error: This expression has type ('a -> bool) list
but an expression was expected of type 'a list
我真的不明白为什么会这样,哪里是A->布尔列表类型是从哪里来的?
哇感谢。我想我误读了list.filter – Rowhawn 2011-04-07 03:50:12
...或List.mem的规范。或'BatList.unique_sort';) – 2011-04-07 15:58:01