chickadee » slset » slset-intersection

slset-intersection LIST_1 LIST_2 ...procedure

Returns the intersection of the lists.

The intersection of lists A and B is comprised of every symbol of A that also occurs in B. Note this implies that an symbol which appears in B and multiple times in list A will also appear multiple times in the result.

The order in which symbols appear in the result is the same as they appear in LIST_1 -- that is, slset-intersection essentially filters LIST_1, without disarranging symbol order. The result may share a common tail with LIST_1.

In the n-ary case, the two-argument list-intersection operation is simply folded across the argument lists.

(slset-intersection '(a b c d e) '(a e i o u)) => (a e)

;; Repeated symbols in LIST1 are preserved.
(slset-intersection '(a x y a) '(x a x z)) => '(a x a)
(slset-intersection '(a x b y b a) '(x a x z) '(a b)) => (a a)

(slset-intersection '(a b c)) => (a b c)     ; Trivial case