emacs-devel
[Top][All Lists]
Advanced

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

Re: Is there already an alist function which gets all matching elements,


From: Alan Mackenzie
Subject: Re: Is there already an alist function which gets all matching elements, not just the first?
Date: Thu, 6 Oct 2022 18:24:29 +0000

Hello, Robert.

On Wed, Oct 05, 2022 at 12:45:00 +0200, Robert Pluim wrote:
> >>>>> On Wed, 5 Oct 2022 10:00:10 +0000, Alan Mackenzie <acm@muc.de> said:

>     Alan> Hello, Emacs.
>     Alan> I want to be able to get all matching elements from an alist 
> (thinking
>     Alan> about extending imenu).  Something like

>     Alan>     (assoc-all key list)

>     Alan> which would return a list of matches.  After all, we have functions
>     Alan> which _delete_ all matches from an alist.

>     Alan> Does such a function already exist, perhaps in cl-*.el?

> Just use assoc-delete-all and invert the test:

> (assoc-delete-all mykey myalist (lambda (val key)
>                                   (not (eq val key))))

Thanks for the idea!  But I'd have to copy the alist first, and then it
starts to look a bit contrived.

Maybe I should just write a straightforward loop to get this info.

> Robert
> -- 

-- 
Alan Mackenzie (Nuremberg, Germany).



reply via email to

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