Before you tackle the homework, remind yourself of our general hw policies.
(2 pts, automatic)
Take the
learning
style assessment survey.
(If you've already taken this assessment in the past, you don't need to repeat it.)
The verification-question is:
Of your four resulting scores, how many of of them are even numbers?
(Mine were all odd -- i'm suspicious!)
(You do not need to report which classification you are -- we just want you aware of the fact that learning styles and teaching styles may jibe worse or better for individuals; this lets you provide better constructive feedback for the prof!)
For the set implementionation given in Lecture 1, write the functions
;; set-: Set, Set --> Set ;; Return the set-difference of A and B ;; (define (set- A B) ...) ;; cross-product: Set, Set --> Set ;; Return the cartesian cross-product of A and B. ;; NB See text "cartesian product"; ;; this is not the cross-product from 3-d vector calc. ;; (define (cross-product A B) ...)(For your test cases, feel free to experiment with drscheme's new test-suite tool.)
As throughout comp210, good code should strive to meet the definition as closely as possible. (For instance, compare the code for set-union and set-intersection with the book's definition of union and intersection.)
One note: since cartesian products deal with ordered pairs, you'll need to decide how to represent these in your program. You have some latitude on this.
(In general, lists are a perfectly acceptable representations of tuples. Still, distinguish between functions that accept/return tuples from those that work on lists -- just as you'd distinguish between functions that return colors vs strings, even if you happen to represent colors as strings of red-green-blue values.)
One remote caution: in scheme, the name "pair?" is built-in,
but it does not mean a-list-of-exactly-two-elements;
it's actually just another name for cons?.
(If curious, check help-desk for "improper list".)
Fortunately this shouldn't be an issue;
if you define-struct pair, then the built-in name is
shadowed with the new structure-checking-predicate,
as you'd expect.