[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Setting the nth element of a list
From: |
Barry Margolin |
Subject: |
Re: Setting the nth element of a list |
Date: |
Thu, 04 Jun 2009 22:25:19 -0400 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article
<8a7c4d36-195d-4517-827e-7fbeca7ae03f@r34g2000vba.googlegroups.com>,
Nordlöw <per.nordlow@gmail.com> wrote:
> This simple example changes the second element in the list x:
>
> (setq x '(a nil c))
> (setcar (cdr x 'b)
>
> How do I generalize this to a function that sets (changes) the nth
> element of a list (for side effects only)?
>
> Thanks in advance,
> Nordlöw
(require 'cl-macs)
(setf (nth n x) 'b)
--
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 ***
- Setting the nth element of a list, Nordlöw, 2009/06/04
- RE: Setting the nth element of a list, Drew Adams, 2009/06/04
- Re: Setting the nth element of a list, Lennart Borgman, 2009/06/04
- Re: Setting the nth element of a list,
Barry Margolin <=
- Re: Setting the nth element of a list, Nordlöw, 2009/06/05
- Re: Setting the nth element of a list, Nordlöw, 2009/06/05
- Re: Setting the nth element of a list, Pascal J. Bourguignon, 2009/06/05
- Re: Setting the nth element of a list, Nordlöw, 2009/06/05
- Re: Setting the nth element of a list, Pascal J. Bourguignon, 2009/06/05
- Re: Setting the nth element of a list, bigfaceworm, 2009/06/05
- Re: Setting the nth element of a list, Miles Bader, 2009/06/06
- Re: Setting the nth element of a list, Barry Margolin, 2009/06/05