|
From: | Alan Mackenzie |
Subject: | Re: How could I modify list element? |
Date: | 9 Dec 2008 16:37:13 +0100 |
Date: | Tue, 9 Dec 2008 16:37:13 +0100 (CET) |
On Tue, 9 Dec 2008, 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???
Try this (not tested): (defun change-nth (liszt, n, nieuw) (while (> n 0) (setq liszt (cdr liszt) n (1- n))) (if liszt (setcar liszt nieuw))) -- Alan Mackenzie (Nuremberg, Germany).
[Prev in Thread] | Current Thread | [Next in Thread] |