all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Is there equivalent internal function for this list-has-elements?
@ 2020-10-18 19:37 Jean Louis
  2020-10-18 20:43 ` Stefan Monnier
  2020-10-18 20:58 ` tomas
  0 siblings, 2 replies; 9+ messages in thread
From: Jean Louis @ 2020-10-18 19:37 UTC (permalink / raw)
  To: help-gnu-emacs


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



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-10-19 20:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-18 19:37 Is there equivalent internal function for this list-has-elements? Jean Louis
2020-10-18 20:43 ` Stefan Monnier
2020-10-19  7:15   ` tomas
     [not found]   ` <20201019180655.GL19325@protected.rcdrun.com>
     [not found]     ` <jwvpn5ef5dx.fsf-monnier+emacs@gnu.org>
2020-10-19 20:15       ` Jean Louis
2020-10-18 20:58 ` tomas
2020-10-18 21:21   ` Joost Kremers
2020-10-19  6:57     ` tomas
2020-10-19 18:08     ` Jean Louis
2020-10-19 18:23   ` Jean Louis

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.