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

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

Adding many elements to a list


From: Nordlöw
Subject: Adding many elements to a list
Date: Fri, 18 Sep 2009 06:15:54 -0700 (PDT)
User-agent: G2/1.0

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


reply via email to

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