Question: Use ML patterns to write a function union ( S 1 , S 2 ) that returns the union of sets S 1 and S

Use ML patterns to write a function union (S1, S2) that returns the union of sets S1 and S2. We implement sets as unordered lists of elements, without repetitions. Hint: use/call the function member from Q1 to check whether an element belongs to a set or not.
I used this code as my function member for Q1:
fun member(e,L)=
if null L
then false
else if e= hd(L)
then true
else member(e,tl(L));

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 Programming Questions!