List SETs By Kelly Roach. Last Revised 21-Jul-84. LSET contains functions for operating on sets and bags implemented as lists. Comments on the LSET package may be sent to ROACH.PA. Set operations like LUNION comes in several flavors. LUNION takes multiple arguments and uses EQUAL LUNION2 takes 2 arguments and uses EQUAL LUNIONQ takes multiple arguments and uses EQ LUNIONQ2 takes 2 arguments and uses EQ Set operations, which do tests with EQUAL, assume that the args that are passed to them are in LSETIFY form-- that is, there are no EQUAL duplicates within any arg. Set operations, which do tests with EQ, assume that the args that are passed to them are in LSETIFYQ form--there are no EQ duplicates within any arg. It isn't necessary that the user call LSETIFY or LSETIFYQ, if the user can guarantee that the args to LUNION, etc. do not have EQUAL or EQ duplicates respectively. Basic set operations: UNION: LUNION, LUNIONQ, LUNION2, LUNIONQ2 INTERSECT: LINTERSECT, LINTERSECTQ, LINTERSECT2, LINTERSECTQ2 SUBTRACT: LSUBTRACT, LSUBTRACTQ, LSUBTRACT2, LSUBTRACTQ2 Miscellaneous useful set functions: (LUNIFY E L) Returns LUNION of (LIST E) and L. (LUNIFYQ E L) Returns LUNIONQ of (LIST E) and L. (LSETIFY L) Returns L with all EQUAL duplicates deleted. (LSETIFYQ L) Returns L with all EQ duplicates deleted. (LSUBSET X Y) Returns T iff X is a subset of Y. (LSUBSETQ X Y) Similar to LSUBSET but uses EQ. (LEQUAL X Y) Returns T iff X equals Y. (LEQUALQ X Y) Returns T iff X equals Y using EQ. Bags (also known as multiset) are unordered lists similar to sets, but elements of bags may appear more than once inside the same bag. Thus, (X Y X A A) and (A X Y X A) represent the same bag containing 2 occurences of A, 2 occurences of X, and 1 occurence of Y. There is no BBAGIFY or BBAGIFYQ functions similar to LSETIFY and LSETIFYQ since all finite undotted lists are already bags. Basic bag operations: UNION: BUNION, BUNIONQ, BUNION2, BUNIONQ2 INTERSECT: BINTERSECT, BINTERSECTQ, BINTERSECT2, BINTERSECTQ2 SUBTRACT: BSUBTRACT, BSUBTRACTQ, BSUBTRACT2, BSUBTRACTQ2 Miscellaneous useful bag functions: (BUNIFY E L) Returns BUNION of (LIST E) and L. (BUNIFYQ E L) Returns BUNIONQ of (LIST E) and L. (BSUBBAG X Y) Returns T iff X is a subbag of Y. (BSUBBAGQ X Y) Similar to BSUBBAG but uses EQ. (BEQUAL X Y) Returns T iff X equals Y. (BEQUALQ X Y) Returns T iff X equals Y using EQ.