[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
adding `find-if' to Emacs Lisp
From: |
Oliver Scholz |
Subject: |
adding `find-if' to Emacs Lisp |
Date: |
Mon, 20 Jan 2003 08:07:21 +0100 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.3.50 (i386-mingw-nt5.1.2600) |
I recently wrote the function `find-if' as an primitive in C, in order
to teach myself C and gain some insights into Emacs' internals at the
same time (patch attached). Actually it was meant as toy code only,
but then again, I thought, it could be worth something by accident.
Whether the code I wrote is worth something or not, I'd like to see a
function that returns the first element of a sequence which satisfies
a predicate function added to the core of Emacs Lisp. I quite often
find myself writing something like this:
(defun my-find-if (predicate list)
(catch 'found
(dolist (elt list nil)
(when (funcall predicate elt)
(throw 'found elt)))))
(my-find-if 'stringp '(alpha "beta" gamma))
Oliver
fns.diff
Description: Text Data
--
Oliver Scholz 1 Pluviôse an 211 de la Révolution
Taunusstr. 25 Liberté, Egalité, Fraternité!
60329 Frankfurt a. M. http://www.jungdemokratenhessen.de
Tel. (069) 97 40 99 42 http://www.jdjl.org
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- adding `find-if' to Emacs Lisp,
Oliver Scholz <=