LAB 1 - Problems About Sets
13 September 1999
Download the jilab1.cl Lab1 LISP source file (Use Save Link As...)
Testing Instructions
1. Load the jilab1.cl file into you LISP system.
2. Call the following automatic test functions to test the lab1 functions:
testunion
testintersection
testldifference
testintersectp
testsamesetp
Assignment Requirements
1. Define UNION. The union of two sets is a set containing all the elements that are in either of the two sets.
2. Define INTERSECTION. The intersection of two sets is a set containing only the elements that are in both of the sets.
3. Define LDIFFERENCE. The difference of two sets, the IN set
and the OUT set, is what remains of the set IN
after all the elements that are also elements of the set OUT are removed.
4. Define INTERSECTP, a predicate which tests whether two sets
have any elements in common. It is to return
NIL if the two sets are disjoint.
5. Define SAMESETP, a predicate which tests whether two sets contain
the same elements. Note that the two
lists representing the sets may be arranged in different orders.
Notes on Source Code
1. To avoid potential conflicts with any existing functions provided by the LISP compiler, I start all the function names with "JI-". The resulting function names are JI-UNION, JI-INTERSECTION, JI-LDIFFERENCE, JI-INTERSECTP, and JI-SAMESETP.
2. It is assumed that only lists will be provided as input arguments for each function call. Non-list arguments will case an ERROR.
3. For INTERSECTP, I made an arbritrary decision that the INTERSECTP of two empty set arguments is TRUE, that an empty set does intersect with another empty set. This may not be mathematically correct, but I could not find a math book that stated what the correct result should be for this predicate test.
4. The assignment source was developed on a Windows NT 4.0 PC
using the free (student?) version of Allegro
CL Lite 5.0.1.