Question: Code in SML/NJ -1powerset This function takes a set of integers S and returns a list of the subsets of S. For example, powerset((3.[2,7,4])) may

Code in SML/NJ
 Code in SML/NJ -1powerset This function takes a set of integers

-1powerset This function takes a set of integers S and returns a list of the subsets of S. For example, powerset((3.[2,7,4])) may return [(0.0),[2]).(1,17(1,[4]), (2,[2,7,(2.[2,4.(2, (7,4]),(3.[2,7,4])] because 2(2,7,4)-(D, {2}, {7), {4), 2,73, 2,4), {7.4;, {2,7,4)3. The order of elements in lists returned by powerset is irrelevant. -2ipowerset This function takes a list L of sets and tests whether there exists a set S such that powerset(S) -L. If such an S exists then ipowerset returns SOME S; otherwise ipowerset returns NONE. For example, ipowerset([(1,[3.(1,[7]), (0, 1).(2,[7,3)] may return SOME (2,[7,3]) because 27,3; - { {31, {7), , 17,3 } } , while ipowerset([( 1[3]),( I ,[7]),(2, [7,3]) returns NONE. sample execution - powerset(E); val it [(0,1 in*int list) list -val P = powerset(S): val P= 12,7,4)] (int*int list) list ipowerset(P); val it SOME (3,[2,7,4]): (intint list) option 4 ipowerset(IED; val it SOME (0,) int*int list) option -ipowerset (I(0,ID.(1,12).(1,17DD; val it = NONE : (int * int list) option -1powerset This function takes a set of integers S and returns a list of the subsets of S. For example, powerset((3.[2,7,4])) may return [(0.0),[2]).(1,17(1,[4]), (2,[2,7,(2.[2,4.(2, (7,4]),(3.[2,7,4])] because 2(2,7,4)-(D, {2}, {7), {4), 2,73, 2,4), {7.4;, {2,7,4)3. The order of elements in lists returned by powerset is irrelevant. -2ipowerset This function takes a list L of sets and tests whether there exists a set S such that powerset(S) -L. If such an S exists then ipowerset returns SOME S; otherwise ipowerset returns NONE. For example, ipowerset([(1,[3.(1,[7]), (0, 1).(2,[7,3)] may return SOME (2,[7,3]) because 27,3; - { {31, {7), , 17,3 } } , while ipowerset([( 1[3]),( I ,[7]),(2, [7,3]) returns NONE. sample execution - powerset(E); val it [(0,1 in*int list) list -val P = powerset(S): val P= 12,7,4)] (int*int list) list ipowerset(P); val it SOME (3,[2,7,4]): (intint list) option 4 ipowerset(IED; val it SOME (0,) int*int list) option -ipowerset (I(0,ID.(1,12).(1,17DD; val it = NONE : (int * int list) option

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!