Lab 0
Welcome to the first lab
Become familiar with our lab procedures
Reacquaint ourselves with DrRacket
Write (recursive) function that determine the intersection and the union of two sets
Open a command line window. Your current working directory will be your home directory
Create a directory, “labs” (you can see the “man”ual pages for mkdir for more information)
Create a directory underneath labs, “lab0” (see the -p option in the man pages for mkdir if you need help)
Download the following files into your ~/labs/lab0 directory
-
-
open DrRacket using the “drracket” command from the terminal window
Open up the “lab0-template.scm” file in the Definitions window. Peruse the code and add your name where necessary.
Rename the file you are editing File/save as… (at least remove the template moniker!)
Consider the following problem statement and the associated (working!) code:
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.
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.
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.