Assignment VII

Due date Monday December 4.

Assignment VII: Scheme.
1. Write a function Weave, that takes three lists of the same lenght, and builds a list of triples with the corresponding entries in each list. For example, if the inputs are (English, day, book), (Francais, jour, livre), and (Espanol, dia, libro), the function returns the list:

((English, Francais, Espanol), (day, jour, dia), (book, livre, libro)).

2. We can use sets to represent lists. A set is an unordered collection with no duplicates. Define the following functions:

a) set? applies to a list, and returns true if the list contains no duplicates. The built-in predicate member is useful here.

b) make-set takes and arbitrary list and removes duplicates in it. thereby creating the corresponding set.

c) set-equal returns true if two lists that are sets have the same elements, in any order.

d) set-intersect is a binary operation that returns the set of elements common to two sets.

e) power-set build the set of all subsets of a set. For example, (power-set ' (a b c)) yields:

(() (a) (b) (c) (a b) (b c) (a c) (a b c))

The critical step here is to understand how the power-set is built recursively out of the power-set of a set with one fewer element. A useful additional function here is one that takes a function, a value, and a list of lists, and returns the result of applying the function to that value and each element of the list (something like map, but where the function takes two arguments).

f) The elements of a set are arbitrary, and can themselves be sets. Therefore, membership should be defined in terms of set equality, and viceversa. Write the proper definitions for set-member and set-equal that handle arbitrary sets.