Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
-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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started