)私は SML を始めたばかりで、L1 と L2 の 2 つのリストを取り、両方に出現する要素のリストを返す関数を作成しようとしています。これは私がこれまでに持っているものです:
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);
エラーがどこにあるのかよくわかりません。