CISC-280 Program Development Techniques

Homework 6: Using Multiple Set Representations

Due: Thursday, November 6, 2008

In this assignment you will use the idea of Data-Directed Programming to produce generic procedures for operating on sets. In the text, three different representations of sets are discussed. For this assignment we will concentrate on just two of them:: unordered list representation and ordered list representation. You should use the tags unordlst and ordlst to tag sets using the two representations.

Part 1: Representation Specific Procedures

For each representation, you will need the following functions. You will need to write the make-set functions but the other functions can be found in the scheme file associated with Slides11 which can be found here.

Part 2: Data Directed Programming

Using the support code from chapter two and the class notes which can be found in the file hw6-data-directed.ss, create and use a table in the data directed approach to generic procedures.  Install, define the general functions by calling apply-generic, and then call the procedures written in Part 1 on sets formed by both representation choices. (This means you may wish to retain two different make-set functions in order to get sets in the different representations.) You may assume for this exercise that we only perform an operation on two sets of the same type.

Remember that you can use procedures from a separate scheme file by calling (load "aux-file-name.scm")

Part 3: Message Passing

Write procedures in the message passing style for adjoin and union for sets represented as ordered lists. You may assume that a set to be passed to union is of the same type.