Lab 0

Welcome to the first lab

  • Objectives:
  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

  • To begin:
  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

  • Next:
  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.

  • Hint: Consider the testing first how many test cases should you have? Then - what is the base case (and how would you test it?) And then, how would you break down the “other” case(s) and test(s)? Again: You should consider the test cases first. At minimum, how many are there for the non-base cases?

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.

  • Click on FILE menu ⇒ “SAVE OTHER” ⇒ “SAVE INTERACTIONS AS TEXT”.
  • Don't overwrite existing files! Use lab0-interactions or something similar as the file name.
  • TO SUBMIT YOUR LAB0 DIRECTORY (assuming that I setup dropbox!) - use the command line interface. cd into your ~/labs directory, issue the command, “submit145 lab0 lab0” without the quotes. Ask for help if this command is not successful.