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: Navy Cheng
Subject: Re: How to use a symbol and its value to create alist?
Date: Wed, 12 Aug 2015 09:35:48 +0800
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Aug 11, 2015 at 07:21:15PM -0500, Barry Margolin wrote:
> 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)))
> 
Thank you for your help, This is what I want.




reply via email to

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