all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* append - bug or feature?
@ 2010-07-27  4:05 TheFlyingDutchman
  2010-07-27  4:21 ` Barry Margolin
  0 siblings, 1 reply; 3+ messages in thread
From: TheFlyingDutchman @ 2010-07-27  4:05 UTC (permalink / raw)
  To: help-gnu-emacs

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?


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: append - bug or feature?
  2010-07-27  4:05 append - bug or feature? TheFlyingDutchman
@ 2010-07-27  4:21 ` Barry Margolin
  2010-07-27 11:45   ` TheFlyingDutchman
  0 siblings, 1 reply; 3+ messages in thread
From: Barry Margolin @ 2010-07-27  4:21 UTC (permalink / raw)
  To: help-gnu-emacs

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 ***


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: append - bug or feature?
  2010-07-27  4:21 ` Barry Margolin
@ 2010-07-27 11:45   ` TheFlyingDutchman
  0 siblings, 0 replies; 3+ messages in thread
From: TheFlyingDutchman @ 2010-07-27 11:45 UTC (permalink / raw)
  To: help-gnu-emacs


>
> 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.
>

Thanks for the reply. Glad to hear they have some use.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-27 11:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-27  4:05 append - bug or feature? TheFlyingDutchman
2010-07-27  4:21 ` Barry Margolin
2010-07-27 11:45   ` TheFlyingDutchman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.