From: pjb@informatimago.com (Pascal J. Bourguignon)
To: help-gnu-emacs@gnu.org
Subject: Re: Adding Lists/Sequences
Date: Tue, 23 Sep 2008 21:26:19 +0200 [thread overview]
Message-ID: <873ajqackk.fsf@hubble.informatimago.com> (raw)
In-Reply-To: mailman.19769.1222183171.18990.help-gnu-emacs@gnu.org
Thierry Volpiatto <thierry.volpiatto@gmail.com> writes:
> Nordlöw <per.nordlow@gmail.com> writes:
>
>> Is there a general function, say foo, that adds lists or, even better,
>> sequences together?
>>
>> I want this
>> (foo '("a" "b") '("c" "d"))
>> to evaluate to
>> '("a" "b" "c" "d")
>
> ,----
> | ELISP> (nconc '("a" "b" "c") '("d" "e" "f"))
> | ("a" "b" "c" "d" "e" "f")
> `----
Very bad!
(defun bad-bad (tail)
(nconc '(a b c) tail))
(bad-bad '(1 2 3)) --> (a b c 1 2 3)
(bad-bad '(4 5 6)) --> (a b c 1 2 3 4 5 6) ; !!!
NEVER use a destructive function on literal data!
> Note: `append' is not destructive
append is much better, but be careful that it shares the tail, so you
must consider the result as a literal data, unless you have consed the
tail yourself.
--
__Pascal_Bourguignon__
next prev parent reply other threads:[~2008-09-23 19:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-23 11:46 Adding Lists/Sequences Nordlöw
2008-09-23 11:52 ` Joost Kremers
2008-09-23 13:22 ` Nordlöw
2008-09-23 15:06 ` Tassilo Horn
2008-09-23 15:28 ` Thierry Volpiatto
[not found] ` <mailman.19769.1222183171.18990.help-gnu-emacs@gnu.org>
2008-09-23 19:26 ` Pascal J. Bourguignon [this message]
2008-09-23 20:48 ` Thierry Volpiatto
2008-09-23 22:11 ` David Kastrup
2008-09-24 7:09 ` Thierry Volpiatto
2008-09-24 9:28 ` Nikolaj Schumacher
2008-09-24 9:55 ` Thierry Volpiatto
2008-09-24 14:50 ` Drew Adams
2008-09-24 15:31 ` Thierry Volpiatto
2008-09-24 15:28 ` David Kastrup
2008-09-24 18:03 ` Thierry Volpiatto
2008-09-24 15:49 ` Drew Adams
2008-09-24 17:59 ` Thierry Volpiatto
[not found] ` <mailman.19799.1222239593.18990.help-gnu-emacs@gnu.org>
2008-09-25 5:27 ` Tim X
2008-09-25 20:34 ` David Kastrup
2008-09-25 22:16 ` Pascal J. Bourguignon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873ajqackk.fsf@hubble.informatimago.com \
--to=pjb@informatimago.com \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).