[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How could I modify list element?
From: |
Thierry Volpiatto |
Subject: |
Re: How could I modify list element? |
Date: |
Tue, 09 Dec 2008 18:26:17 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
richardeng <richardeng@foxmail.com> writes:
> 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???
Sorry one func was missing in precedent post:
,----
| (defun tv-move-element-in-list (name-elm lis where)
| "move element `name-elm' of list `lis' to index `where'
| in list `lis'.
| `name-elm' have the form of element in list.
| `lis' is a LIST
| `where' is an INTEGER"
| (let* ((index-elm (tv-index-elt-list name-elm lis))
| (start-part-list (subseq lis 0 where))
| (mod-list (append (remove name-elm start-part-list)
| (cons name-elm
| (remove name-elm (subseq lis where))))))
| mod-list))
`----
--
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France