关于一个较旧的问题Find if Duplicates Exist SML NJ,如果我想要相反的结果:
[1,2,2,3,4,5,6] should return false
[1,2,3,4,5,6,7] should return true
[1,2,3,4,5,6,1] should return false
我怎样才能拥有它:
fun duplicated [] = false
| duplicated (x::xs) = (List.exists (fn y => x = y) xs) orelse (duplicated xs)
例如,
fun non_duplicated ps =
case ps of
[] => false
| x::xs' => (List.exists (fn y => x<>y) xs') andalso (non_duplicated xs')
不起作用。
为什么???谢谢。