Question: Write a function powerset: 'a list -> 'a list list powerset 1 returns the powerset of the set of values in an input list
Write a function powerset: 'a list -> 'a list list powerset 1 returns the powerset of the set of values in an input list 1 (the power set of a Set A is defined as the set of all subsets of the Set A including the Set itself). The order in the returned nested list (and each list element within) does not matter. let powerset 1 = (* YOUR CODE HERE *) powerset [1;2;3];; :int list list = [[1]; [1; 2]; [1; 2; 3]; [1; 3]; [2]; [2; 3]; [3]] powerset [];;
Step by Step Solution
3.45 Rating (148 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
