unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).