|
From: | Andreas Politz |
Subject: | Re: How could I modify list element? |
Date: | Tue, 09 Dec 2008 17:36:21 +0100 |
User-agent: | Mozilla-Thunderbird 2.0.0.17 (X11/20081018) |
richardeng wrote:
Hi all, setcar/setcdr is not convenient. In a long list, ex. (setq a '(a b c d e f g)) I want to change 'e to 'E. I need a function: (set-list-elt list old-elt new-elt) How? translate list to vector, modify, then turn it back???
Why don't you ... (let ((list '(a b c d e))) (or (and (require 'cl nil t) (substitute 'E 'e list)) (mapcar #'(lambda (elt) (if (eq elt 'e) 'E elt)) list))) -ap
[Prev in Thread] | Current Thread | [Next in Thread] |