Function: seq-intersection

seq-intersection is a byte-compiled function defined in seq.el.gz.

Signature

(seq-intersection SEQUENCE1 SEQUENCE2 &optional TESTFN)

Documentation

Return copy of SEQUENCE1 with elements that appear in SEQUENCE2 removed.

"Equality" of elements is defined by the function TESTFN, which
defaults to equal. This does not modify SEQUENCE1 or SEQUENCE2.

Other relevant functions are documented in the sequence group.

View in manual

Shortdoc

;; sequence
(seq-intersection '(1 2 3) '(2 3 4))
    => (2 3)

Aliases

ediff-intersection (obsolete since 28.1) url-intersection (obsolete since 28.1)

Implementations

(seq-intersection SEQUENCE1 SEQUENCE2 &optional TESTFN) in `seq.el'.

Undocumented

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/seq.el.gz
;;;###autoload
(cl-defgeneric seq-intersection (sequence1 sequence2 &optional testfn)
  "Return copy of SEQUENCE1 with elements that appear in SEQUENCE2 removed.
\"Equality\" of elements is defined by the function TESTFN, which
defaults to `equal'.
This does not modify SEQUENCE1 or SEQUENCE2."
  (seq-reduce (lambda (acc elt)
                (if (seq-contains-p sequence2 elt testfn)
                    (cons elt acc)
                  acc))
              (seq-reverse sequence1)
              '()))