Lab 0

Welcome to the first lab

  1. Become familiar with our lab procedures
  2. Reacquaint ourselves with DrRacket
  3. Write (recursive) function that determine the intersection and the union of two sets

  1. Open a command line window. Your current working directory will be your home directory
  2. Create a directory, “labs” (you can see the “man”ual pages for mkdir for more information)
  3. Create a directory underneath labs, “lab0” (see the -p option in the man pages for mkdir if you need help)
  4. Download the following files into your ~/labs/lab0 directory
  5. open DrRacket using the “drracket” command from the terminal window

  1. Open up the “lab0-template.scm” file in the Definitions window. Peruse the code and add your name where necessary.
  2. Rename the file you are editing File/save as… (at least remove the template moniker!)
  3. Consider the following problem statement and the associated (working!) code:
    1. Define a function, called SUBSET?, that takes two inputs, AA and BB, that are lists representing sets. The function should return #t (or something that signifies TRUE) if AA is a subset of BB; #f otherwise.
  4. Review the test cases. Can you add at least one appropriate TESTER expression?

Problem 1

Define a function, called INTERSECTION, that takes two inputs, AA and BB, that are lists representing sets. The function should return a list representing the INTERSECTION of the two input lists. Note: If the input lists do not have any duplicates, then neither should the output list. However, you need not define any kind of “remove-duplicates” function.

Problem 2

Define a function, called UNION, just like the first problem. That is, the function takes two inputs, AA and BB, that are lists representing sets. The function should return a list representing the INTERSECTION of the two input lists. Note: If the input lists do not have any duplicates, then neither should the output list. However, you need not define any kind of “remove-duplicates” function.

Are we done yet?

Your lab work is not complete until you have demonstrated working code to a coach (or professor) and your name is recorded as being complete! When you are done, you should save your interactions window output and submit your work.