[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: until-found
From: |
Andreas Röhler |
Subject: |
Re: until-found |
Date: |
Fri, 11 Dec 2009 11:33:42 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20081227) |
tomas@tuxteam.de wrote:
> On Thu, Dec 10, 2009 at 01:50:01PM +0100, Andreas Roehler wrote:
>> Hi,
>
>> given a list or a list of lists:
>> list shall be returned, if it contains a certain member.
>
>> I'm pretty sure a general form exists, but ignore it.
>
> [...]
>
>> (defun until-found (search-string liste)
>> (let ((liste liste) element)
>> (while liste
>> (if (member search-string (car liste))
>> (setq element (car liste) liste nil))
>> (setq liste (cdr liste)))
>> element))
>
>
> Have a look at assoc -- it might be what you are looking for.
>
> If you need more flexibility, cl's assoc* (where you can specify, among
> other things, the comparison function) might fit your bill.
>
> Regards
> -- tomás
Hi Tomas,
assoc tells, it compares some key and the car of a list:
"Return non-nil if KEY is `equal' to the car of an element of LIST."
Its related, but slightly different IMO.
The form I'm looking for returns list, if an element is member of - equality
of whole list returned by car is not at stake.
Thanks anyway
Andreas