Function: seq-union

seq-union is an autoloaded and byte-compiled function defined in seq-25.el.

Signature

(seq-union SEQUENCE1 SEQUENCE2 &optional TESTFN)

Documentation

Return a list of all the elements that appear in either SEQUENCE1 or SEQUENCE2.

"Equality" of elements is defined by the function TESTFN, which
defaults to equal.

Other relevant functions are documented in the sequence group.

Probably introduced at or before Emacs version 28.1.

Shortdoc

;; sequence
(seq-union '(1 2 3) '(3 5))
    => (1 2 3 5)

Aliases

ediff-union (obsolete since 28.1)

Implementations

(sequence1 sequence2 &optional testfn) in `seq-25.el'.

Undocumented

Source Code

;; Defined in ~/.emacs.d/elpa/seq-2.24/seq-25.el
;;;###autoload
(cl-defgeneric seq-union (sequence1 sequence2 &optional testfn)
  "Return a list of all the elements that appear in either SEQUENCE1 or SEQUENCE2.
\"Equality\" of elements is defined by the function TESTFN, which
defaults to `equal'."
  (let* ((accum (lambda (acc elt)
                  (if (seq-contains-p acc elt testfn)
                      acc
                    (cons elt acc))))
         (result (seq-reduce accum sequence2
                             (seq-reduce accum sequence1 '()))))
    (nreverse result)))