unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Nicolas Richard <theonewiththeevillook@yahoo.fr>
To: drain <aeuster@gmail.com>
Cc: Help-gnu-emacs@gnu.org
Subject: Re: setcdr question
Date: Tue, 02 Jul 2013 11:06:58 +0200	[thread overview]
Message-ID: <87obal1gb1.fsf@yahoo.fr> (raw)
In-Reply-To: <1372718770419-290941.post@n5.nabble.com> (drain's message of "Mon, 1 Jul 2013 15:46:10 -0700 (PDT)")

drain <aeuster@gmail.com> writes:

> (setq list '(Trevor Jason John Alex Max))
> (setcdr (nthcdr (1- 4) list) 'Christina)

As your question was already answered, I allow me to digress slightly
in suggesting that you may like setf for such operations:

(let ((list '(Trevor Jason John Alex Max)))
  (setf (nth (1- 4) list) 'Christina)
  list)
=> (Trevor Jason John Christina Max)

-- 
Nico.



  parent reply	other threads:[~2013-07-02  9:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-01 22:46 setcdr question drain
2013-07-02  2:12 ` Pierre Lorenzon
2013-07-02  9:06 ` Nicolas Richard [this message]
2013-07-02  9:17   ` Teemu Likonen
2013-07-02 22:17     ` drain
2013-07-02 22:26       ` drain
2013-07-03  9:13       ` Pierre Lorenzon
     [not found]       ` <mailman.90.1372804018.12400.help-gnu-emacs@gnu.org>
2013-07-03 13:04         ` Rustom Mody
2013-07-04 19:19           ` drain

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=87obal1gb1.fsf@yahoo.fr \
    --to=theonewiththeevillook@yahoo.fr \
    --cc=Help-gnu-emacs@gnu.org \
    --cc=aeuster@gmail.com \
    /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).