Function: seq-union
seq-union is a byte-compiled function defined in seq.el.gz.
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.
This does not modify SEQUENCE1 or SEQUENCE2.
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
(seq-union 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-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'.
This does not modify SEQUENCE1 or SEQUENCE2."
(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)))