1
)我刚刚开始使用SML,并试图编写一个函数,它带有两个列表L1和L2,并返回两个列表中出现的元素。这是我迄今为止:返回两个列表中出现的元素列表--SML
fun exists x nil = false | exists x (h::t) = (x = h) orelse (exists x t);
fun listAnd L1 nil = nil
| listAnd nil L2 = nil
| listAnd L1 L2 = if exists(hd(L1) L2) = true then hd(L1)::(listAnd(tl(L1) L2)) else listAnd(tl(L1) L2);
我不太确定错误在哪里。