help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: member returns list (was: Re: To `boundp' or not to `boundp'?)


From: Barry Margolin
Subject: Re: member returns list (was: Re: To `boundp' or not to `boundp'?)
Date: Wed, 02 Sep 2015 12:25:39 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <mailman.363.1441150201.19560.help-gnu-emacs@gnu.org>,
 Emanuel Berg <embe8573@student.uu.se> wrote:

> Barry Margolin <barmar@alum.mit.edu> writes:
> 
> > ... MEMBER, which intuitively seems like it would
> > just return a boolean, but actually returns the tail
> > of the list where the element was found.
> 
> Yes, and I have wondered about that. Is it useful,
> perhaps with the use of `car' (?) as in:
> 
>     (car (member 2 '(1 2 3))) ; 2
>     (car (member 0 '(1 2 3))) ; nil
> 
> Or is it some "leftover optimization" thing where
> `cdr' is faster than returning `t', and can be used
> the same way?
> 
> Or is it something else?

It could be useful for something like

(length (member item list))

Or it could be used in a loop, where you repeat the operation with the 
list that it returned.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


reply via email to

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