help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Is there equivalent internal function for this list-has-elements?


From: Jean Louis
Subject: Is there equivalent internal function for this list-has-elements?
Date: Sun, 18 Oct 2020 22:37:01 +0300

For the below function `list-has-elements' maybe there exist some
internal Emacs function that checks for list that elements that are
contained in the haystak? Is there any?

Other question is, if there is any function other than pushnew, if I
do not wish to use the pushnew? I can maybe just make a check if
element is in the list and then simply push?

(defun list-has (needle haystack)
  "Returns elements of haystack that contain needle, case insensitive"
  (let ((nlist))
    (dolist (element haystack (reverse nlist))
      (when (string-match needle element)
        (pushnew element nlist)))))

(defun list-has-elements (needles haystack)
  "Returns elements of haystack that contain needle, case insensitive"
  (if needles
      (let* ((needle (pop needles))
             (haystack (list-has needle haystack)))
        (list-has-elements needles haystack))
    haystack))

Thanks,
Jean



reply via email to

[Prev in Thread] Current Thread [Next in Thread]