[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to use a symbol and its value to create alist?
From: |
Barry Margolin |
Subject: |
Re: How to use a symbol and its value to create alist? |
Date: |
Tue, 11 Aug 2015 19:21:15 -0500 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article <mailman.8135.1439301205.904.help-gnu-emacs@gnu.org>,
Navy Cheng <navych@126.com> wrote:
> For example:
>
> (setq a 1)
> (setq b 2)
> (setq c 3)
>
> How can I a alist, like:
> ((a . 1) (b . 2) (c .3))
>
> The value of a, b and c may change, so don't do this like
> (setq tree ((a . 1) (b . 2) (c .3)))
>
> Thank you!
I suspect this is what you want:
(setq tree (list (cons 'a a) (cons 'b b) (cons 'c c)))
or using backquote:
(setq tree `((a . ,a) (b . ,b) (c . ,c)))
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***