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

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

Re: append - bug or feature?


From: Barry Margolin
Subject: Re: append - bug or feature?
Date: Wed, 08 Dec 2010 15:21:10 -0000
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article 
<41bef0ed-8aac-4b8c-a5c1-2906078f3fbd@v6g2000prd.googlegroups.com>,
 TheFlyingDutchman <zzbbaadd@aol.com> wrote:

> The documentation for append says:
> _____________________________________________________
> This function returns a list containing all the elements of sequences.
> The sequences may be lists, vectors, bool-vectors, or strings, but the
> last one should usually be a list. All arguments except the last one
> are copied, so none of the arguments is altered.
> 
> More generally, the final argument to append may be any Lisp object.
> The final argument is not copied or converted; it becomes the CDR of
> the last cons cell in the new list. If the final argument is itself a
> list, then its elements become in effect elements of the result list.
> If the final element is not a list, the result is a "dotted list"
> since its final CDR is not nil as required in a true list.
> ______________________________________________________
> 
> A "dotted list" will blow up functions like length and  append (if it
> is not the last argument). Are there situations in which a "dotted
> list" is more useful than a list - times when you would want to create
> one?

A dotted list is just a particular case of uses of conses for arbitrary 
data structures, rather than true lists.

They're useful for binary trees.  The CAR of each non-leaf node is a 
pointer to the left subtree, the CDR is a pointer to the right subtree.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***


reply via email to

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