unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Adding many elements to a list
@ 2009-09-18 13:15 Nordlöw
  2009-09-18 13:44 ` Pascal J. Bourguignon
  2009-09-18 13:52 ` David Kastrup
  0 siblings, 2 replies; 15+ messages in thread
From: Nordlöw @ 2009-09-18 13:15 UTC (permalink / raw)
  To: help-gnu-emacs

What is the most efficient way of performing lots of successive
appends of elements to the same list?

If we start with defining the list

(setq l '(a b))

then the Emacs manual says that we can use

(nconc l '(c d)))

I have noticed that this works in all cases except when l is nil.
To make this case work aswell we need to do use

(setq l (nconc l '(c d))))


Or can we use setcar or setcdr in a more clever way?

Reflections?
Per Nordlöw


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

end of thread, other threads:[~2009-09-28 20:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-18 13:15 Adding many elements to a list Nordlöw
2009-09-18 13:44 ` Pascal J. Bourguignon
2009-09-18 14:23   ` David Kastrup
2009-09-18 14:48     ` Pascal J. Bourguignon
2009-09-18 14:54       ` David Kastrup
2009-09-18 15:13         ` Pascal J. Bourguignon
2009-09-19  7:34           ` Andreas Politz
2009-09-22  7:07           ` David Kastrup
2009-09-22 11:53             ` Pascal J. Bourguignon
2009-09-22 12:16               ` David Kastrup
2009-09-22 12:37                 ` Pascal J. Bourguignon
2009-09-22 15:18                   ` David Kastrup
2009-09-28 20:03                 ` Samuel Wales
2009-09-18 16:24         ` Thierry Volpiatto
2009-09-18 13:52 ` David Kastrup

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).