Question: Using F# language. Full and complete answer in order to get credit please. Thank you. 1)Write an uncurried F# function cartesian (xs, ys) that takes

Using F# language. Full and complete answer in order to get credit please. Thank you.

1)Write an uncurried F# function cartesian (xs, ys) that takes as input two lists xs and ys and returns a list of pairs that represents the Cartesian product of xs and ys. (The pairs in the Cartesian product may appear in any order.) For example,

 > cartesian (["a"; "b"; "c"], [1; 2]);; val it : (string * int) list = [("a", 1); ("b", 1); ("c", 1); ("a", 2); ("b", 2); ("c", 2)] 

2) An F# list can be thought of as representing a set, where the order of the elements in the list is irrelevant. Write an F# function powerset such that powerset set returns the set of all subsets of set. For example,

 > powerset [1;2;3];; val it : int list list = [[]; [3]; [2]; [2; 3]; [1]; [1; 3]; [1; 2]; [1; 2; 3]] 

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!