Documentation
Test whether SEQ1 ends with SEQ2. In other words: return true if
the last (length seq2) elements of seq1 are equal to seq2.
Source
(defun ends-with (seq1 seq2 &key (test #'eql))
"Test whether SEQ1 ends with SEQ2. In other words: return true if
the last (length seq2) elements of seq1 are equal to seq2."
(let ((length1 (length seq1))
(length2 (length seq2)))
(when (< length1 length2)
;; if seq1 is shorter than seq2 than seq1 can't end with seq2.
(return-from ends-with nil))
(loop
for seq1-index from (- length1 length2) below length1
for seq2-index from 0 below length2
when (not (funcall test (elt seq1 seq1-index) (elt seq2 seq2-index)))
do (return-from ends-with nil)
finally (return t))))
Source Context