Set operations
Operations pretending lists are sets.
Function: -union (list1 list2)
Return a new list of distinct elements appearing in either list1 or list2.
The test for equality is done with equal, or with -compare-fn if that is non-nil.
(-union '(1 2 3) '(3 4 5))
⇒ (1 2 3 4 5)(-union '(1 2 2 4) ())
⇒ (1 2 4)(-union '(1 1 2 2) '(4 4 3 2 1))
⇒ (1 2 4 3)Function: -difference (list1 list2)
Return a new list with the distinct members of list1 that are not in list2.
The test for equality is done with equal, or with -compare-fn if that is non-nil.
(-difference () ())
⇒ ()(-difference '(1 2 3) '(4 5 6))
⇒ (1 2 3)(-difference '(1 2 3 4) '(3 4 5 6))
⇒ (1 2)Function: -intersection (list1 list2)
Return a new list of distinct elements appearing in both list1 and list2.
The test for equality is done with equal, or with -compare-fn if that is non-nil.
(-intersection () ())
⇒ ()(-intersection '(1 2 3) '(4 5 6))
⇒ ()(-intersection '(1 2 2 3) '(4 3 3 2))
⇒ (2 3)Function: -powerset (list)
Return the power set of list.
(-powerset ())
⇒ (nil)(-powerset '(x y))
⇒ ((x y) (x) (y) nil)(-powerset '(x y z))
⇒ ((x y z) (x y) (x z) (x) (y z) (y) (z) nil)Function: -permutations (list)
Return the distinct permutations of list.
Duplicate elements of list are determined by equal, or by -compare-fn if that is non-nil.
(-permutations ())
⇒ (nil)(-permutations '(a a b))
⇒ ((a a b) (a b a) (b a a))(-permutations '(a b c))
⇒ ((a b c) (a c b) (b a c) (b c a) (c a b) (c b a))Function: -distinct (list)
Return a copy of list with all duplicate elements removed.
The test for equality is done with equal, or with -compare-fn if that is non-nil.
Alias: -uniq.
(-distinct ())
⇒ ()(-distinct '(1 1 2 3 3))
⇒ (1 2 3)(-distinct '(t t t))
⇒ (t)Function: -same-items? (list1 list2)
Return non-nil if list1 and list2 have the same distinct elements.
The order of the elements in the lists does not matter. The lists may be of different lengths, i.e., contain duplicate elements. The test for equality is done with equal, or with -compare-fn if that is non-nil.
Alias: -same-items-p.
(-same-items? '(1 2 3) '(1 2 3))
⇒ t(-same-items? '(1 1 2 3) '(3 3 2 1))
⇒ t(-same-items? '(1 2 3) '(1 2 3 4))
⇒ nil