Function: cl-mismatch
cl-mismatch is an autoloaded and byte-compiled function defined in
cl-seq.el.gz.
Signature
(cl-mismatch SEQ1 SEQ2 [KEYWORD VALUE]...)
Documentation
Compare SEQ1 with SEQ2, return index of first mismatching element.
Return nil if the sequences match. If one sequence is a prefix of the other, the return value indicates the end of the shorter sequence.
Keywords supported: :test :test-not :key :start1 :end1 :start2 :end2 :from-end
Aliases
mismatch (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/cl-seq.el.gz
;;;###autoload
(defun cl-mismatch (seq1 seq2 &rest cl-keys)
"Compare SEQ1 with SEQ2, return index of first mismatching element.
Return nil if the sequences match. If one sequence is a prefix of the
other, the return value indicates the end of the shorter sequence.
\nKeywords supported: :test :test-not :key :start1 :end1 :start2 :end2 :from-end
\n(fn SEQ1 SEQ2 [KEYWORD VALUE]...)"
(declare (important-return-value t))
(cl--parsing-keywords ( :test :test-not :key :from-end
(:start1 0) :end1 (:start2 0) :end2) ()
(or cl-end1 (setq cl-end1 (length seq1)))
(or cl-end2 (setq cl-end2 (length seq2)))
(if cl-from-end
(progn
(while (and (< cl-start1 cl-end1) (< cl-start2 cl-end2)
(cl--check-match (elt seq1 (1- cl-end1))
(elt seq2 (1- cl-end2))))
(setq cl-end1 (1- cl-end1) cl-end2 (1- cl-end2)))
(and (or (< cl-start1 cl-end1) (< cl-start2 cl-end2))
(1- cl-end1)))
(let ((p1 (and (listp seq1) (nthcdr cl-start1 seq1)))
(p2 (and (listp seq2) (nthcdr cl-start2 seq2))))
(while (and (< cl-start1 cl-end1) (< cl-start2 cl-end2)
(cl--check-match (if p1 (car p1)
(aref seq1 cl-start1))
(if p2 (car p2)
(aref seq2 cl-start2))))
(setq p1 (cdr p1) p2 (cdr p2)
cl-start1 (1+ cl-start1) cl-start2 (1+ cl-start2)))
(and (or (< cl-start1 cl-end1) (< cl-start2 cl-end2))
cl-start1)))))