Skip to main content
edited tags
Link
Drew
  • 80.9k
  • 10
  • 125
  • 265
Source Link
ideasman42
  • 9.5k
  • 2
  • 38
  • 133

How to check if a list ends with another list?

Currently I'm using a fairly inefficient way to check if one list uses another list at it's end. Is there a more efficient way to do this?

(defun is-in-list (ls-haystack ls-ends-with) (catch 'found (while (not (or (eq ls-haystack t) (null ls-haystack))) (when (eq ls-haystack ls-ends-with) (throw 'found t)) (setq ls-haystack (cdr ls-haystack)))))