[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: |
Ian Zimmerman |
Subject: |
Re: How to use a symbol and its value to create alist? |
Date: |
Tue, 11 Aug 2015 08:21:53 -0700 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On 2015-08-11 21:52 +0800, Navy Cheng wrote:
> (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)))
That's a strange question. Why would you want such a list, how would
it be useful? To look up the value a a symbol, you just use it, for
example:
(setq a 1)
...
(message "a=%d" a)
=> a=1
In some special situations where a symbol is not evaluated (such as when
playing with macros) you may need to use symbol-value. But I'm guessing
you're not at that point.
--
Please *no* private copies of mailing list or newsgroup messages.
Rule 420: All persons more than eight miles high to leave the court.