[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: What to use instead of find-if?
From: |
Drew Adams |
Subject: |
RE: What to use instead of find-if? |
Date: |
Mon, 1 Dec 2008 13:24:19 -0800 |
> So the code I'm thinking about does the following:
> (let ((blah (find-if (lambda (elem)
> (whopping-great-predicatey-thing))
> some-list)))
> (if blah (something using blah) (something else)))
>
> Can anyone suggest a vaguely idiomatic way to do this using
> the built-in constructs of elisp?
There are no doubt lots of ways to do it. Here's one:
(defun my-find-if (pred xs)
(catch 'my-found
(dolist (x xs) (when (funcall pred x) (throw 'my-found x)))
nil))