Function: cl-merge
cl-merge is an autoloaded and byte-compiled function defined in
cl-seq.el.gz.
Signature
(cl-merge TYPE SEQ1 SEQ2 PREDICATE [KEYWORD VALUE]...)
Documentation
Destructively merge the two sequences to produce a new sequence.
TYPE is the sequence type to return, SEQ1 and SEQ2 are the two argument
sequences, and PREDICATE is a less-than predicate on the elements.
Keywords supported: :key
Aliases
merge (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-seq.el.gz
;;;###autoload
(defun cl-merge (type seq1 seq2 pred &rest cl-keys)
"Destructively merge the two sequences to produce a new sequence.
TYPE is the sequence type to return, SEQ1 and SEQ2 are the two argument
sequences, and PREDICATE is a `less-than' predicate on the elements.
\nKeywords supported: :key
\n(fn TYPE SEQ1 SEQ2 PREDICATE [KEYWORD VALUE]...)"
(declare (important-return-value t))
(or (listp seq1) (setq seq1 (append seq1 nil)))
(or (listp seq2) (setq seq2 (append seq2 nil)))
(cl--parsing-keywords (:key) ()
(let ((res nil))
(while (and seq1 seq2)
(if (funcall pred (cl--check-key (car seq2))
(cl--check-key (car seq1)))
(push (pop seq2) res)
(push (pop seq1) res)))
(cl-coerce (nconc (nreverse res) seq1 seq2) type))))