0
我想實現另一組的子集。但是,我無法使用以下示例{{{},1}}和{{1,{}}}進行工作我嘗試了所有我能夠做到的事情。我的主要目標是設定平等,在這種情況下返回true。首先,我想讓我的子集工作,然後實現設置的等式。設置另一組子集SML
datatype expression = SET of expression list | TUPLE of expression list | INT of int
fun member(a,SET y) = List.exists (fn x => x=a) y;
fun member1 (n,nil) = false
| member1 (n, SET h::r) = (n=h) orelse member1 (n,r);
fun isIn value list = List.exists (fn x=>value=x) list;
fun isSubset' ([],s') = true
| isSubset' (e::s,s') = isIn e s' andalso isSubset' (s,s');
fun isSubset(SET s,SET s') = isSubset'(s,s');
fun subsetEQ [] S' = true
| subsetEQ (x::xs) S' = isIn x S' andalso subsetEQ xs S';
fun setEq (SET S,SET S') = (subsetEQ S S') andalso (subsetEQ S' S) ;
val x0 = INT 8;
val x1 = SET [SET[SET[],INT 1]];
val x2 = SET [SET[INT 1,SET[]]];
val x3 = setEq (x1,x2);