[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: replacing a certain element in a list with another
From: |
Klaus Berndl |
Subject: |
Re: replacing a certain element in a list with another |
Date: |
30 Sep 2003 11:59:39 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
On 30 Sep 2003, David Kastrup wrote:
> Klaus Berndl <klaus.berndl@sdm.de> writes:
>
> > Suppose i have the following list:
> >
> > '(a b c d)
> >
> > What is a good way to replace one of the list-elements with another, so
> > foe example replacing the 'c with 'e?
>
> > But: i do not want using any c-functions, so i would prefer a
> > solution without using `substitute'!
>
> Uh, what?
This comes from a recommendation in the elisp-info-manual (Standards -->
Coding conventions"):
* Please don't require the `cl' package of Common Lisp extensions at
run time. Use of this package is optional, and it is not part of
the standard Emacs namespace. If your package loads `cl' at run
time, that could cause name clashes for users who don't use that
package.
However, there is no problem with using the `cl' package at compile
time, for the sake of macros. You do that like this:
(eval-when-compile (require 'cl))
I interpret this ("...for the sake of macros...") so, that at least for
packages for GNU Emacs the code can use cl-macros but should not use any
functions from the cl package. Please correct me if i have misunderstood here
something!?
>
> Anyhow, try
>
> (let ((xxx '(a b c d)))
> (setcar (member 'c xxx) 'e)
> xxx)
Thanks a lot, David!
Ciao,
Klaus
--
Klaus Berndl mailto: klaus.berndl@sdm.de
sd&m AG http://www.sdm.de
software design & management
Thomas-Dehler-Str. 27, 81737 München, Germany
Tel +49 89 63812-392, Fax -220
Re: replacing a certain element in a list with another, Stefan Monnier, 2003/09/30