From: Pascal Bourguignon
Subject: Re: the FIND function applied to cons cells
Date: 
Message-ID: <87ejzxi9or.fsf@thalassa.informatimago.com>
"Jimka" <·····@rdrop.com> writes:

> Is there any common function or idiom which is similar to MEMBER-IF
> but applies its testing function to the cons cell rather than the top
> level
> item?

Well, you can scan the extensive list of sequence functions at:
http://www.lispworks.com/documentation/HyperSpec/Body/c_sequen.htm
and perhaps also the cons functions at:
http:///www.lispworks.com/documentation/HyperSpec/Body/c_conses.htm

But I guess the answer is: No.

> I'd like to do the following
>
> (on-member-if #'(lambda (sub) (eqv 5 (cadr sub)))
>                 '(1 2 3 4 5 6 7 8))
> ===> (4 5 6 7 8)
>
> The function would be easy to write using LOOP, but for completeness it
> would be nice if it took all the same arguments as the MEMBER family of
> functions.

The closest that can be used is maplist, but it conses a partial
result list which is discarted in:

(block :done
   (maplist (lambda (rest) 
               (when (eql 5 (second rest)) 
                  (return-from :done rest)))
            '(1 2 3 4 5 6 7 8 9)))
--> (4 5 6 7 8 9)


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

Nobody can fix the economy.  Nobody can be trusted with their finger
on the button.  Nobody's perfect.  VOTE FOR NOBODY.
From: Kalle Olavi Niemitalo
Subject: Re: the FIND function applied to cons cells
Date: 
Message-ID: <87psjgg3gd.fsf@Astalo.kon.iki.fi>
Pascal Bourguignon <···@informatimago.com> writes:

> The closest that can be used is maplist, but it conses a partial
> result list which is discarted in:

If you want no consing, use MAPL instead.