Question: Implement a scheme predicate called set_equal that takes as input two lists representing sets and returns true if the lists represent the same set and

  1. Implement a scheme predicate called set_equal that takes as input two lists representing sets and returns true if the lists represent the same set and false otherwise. The difference between this predicate and the one predefined in Python. Thus, the call

set_equal ( [1, [2, [3, 4]]], [[[4 , 3], 2], 1] )

should return True and the call

set_equal ( [1, [2, [3, 4]]], [[4, 3 ,2], 1] )

should return False.

Note that here sets can themselves contain sets.

remember that set-equality is not primitive. To say that two sets A and B are equal is equivalent to saying that A is a subset of B and B is a subset of A. So first define a procedure set_subset roughly in this way:

set_subset (A,B)

If the first element of A is not a set, then find out if it is a member of B (use Pythons build-in in operator).

If the first element of A is a set, then find out if there is an identical set within B. Thus, if the first element of B is a set, determine whether every element of the first element of A is in the first element of B.

And if the first element of B is not a set, continue on look for the first element of A in the remainder of B.

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!