|
| From: | Stefan Monnier |
| Subject: | Re: replacing a certain element in a list with another |
| Date: | Tue, 30 Sep 2003 14:16:08 GMT |
| User-agent: | Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 |
> 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?
(mapcar (lambda (x) (if (eq x 'c) 'e x)) <list>)
I'd advise against using `setcar/setcdr' unless you have good reasons to
do it.
Stefan
| [Prev in Thread] | Current Thread | [Next in Thread] |