help-gnu-emacs
[Top][All Lists]
Advanced

[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 <address@hidden>,
 Navy Cheng <address@hidden> 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, address@hidden
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


reply via email to

[Prev in Thread] Current Thread [Next in Thread]