From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Navy Cheng Newsgroups: gmane.emacs.help Subject: Re: How to use a symbol and its value to create alist? Date: Wed, 12 Aug 2015 09:57:13 +0800 Message-ID: <20150812015712.GC22098@debian> References: <87pp2tga8e.fsf@kuiper.lan.informatimago.com> Reply-To: Navy Cheng NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1439344667 16738 80.91.229.3 (12 Aug 2015 01:57:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 12 Aug 2015 01:57:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Aug 12 03:57:38 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZPLIQ-0004aU-5w for geh-help-gnu-emacs@m.gmane.org; Wed, 12 Aug 2015 03:57:38 +0200 Original-Received: from localhost ([::1]:36370 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPLIP-0005w3-Ih for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Aug 2015 21:57:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPLIF-0005vn-4V for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 21:57:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPLIB-0000Ms-35 for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 21:57:27 -0400 Original-Received: from m15-114.126.com ([220.181.15.114]:51223) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPLIA-0000MO-GE for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 21:57:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=7/gw+ +qBHRhQ8ykENv3QJGi0Y8ixw7A3A7BWxSGU+Uc=; b=DCXtnGNQiek6guLAycslV 9Zz6Q6dPWqwAQYxNPiqq83C8mgG5ORAwIiDhLfLtyApTRI04ubO9QskNRrjP8Txm iHtpLOocBQ37dM1MKcC9Ktc0bZFwInt1gplcb/w3Y7UmUjrAoqZRWF1wFfk4iFb0 Wo9yuKGcvIcU5blVvtd3e8= Original-Received: from localhost (unknown [140.207.196.4]) by smtp7 (Coremail) with SMTP id DsmowAB3Pn_5p8pViwMeAA--.665S3; Wed, 12 Aug 2015 09:57:13 +0800 (CST) Content-Disposition: inline In-Reply-To: <87pp2tga8e.fsf@kuiper.lan.informatimago.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-CM-TRANSID: DsmowAB3Pn_5p8pViwMeAA--.665S3 X-Coremail-Antispam: 1Uf129KBjvdXoWruF17tF48Zw17Jw43tF1fWFg_yoW3trX_tw n7AFy7urW5XrZIk3yxtF4DWr4DtFsYvrs3Gay5Jw4vyry3GF4fJFy2q3s2g343AF13JFna kFn0vryYgwn7ujkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU0jQ6PUUUUU== X-Originating-IP: [140.207.196.4] X-CM-SenderInfo: 5qdy5ubk6rjloofrz/1tbicx5UDVUwzHi-JAAAs+ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 220.181.15.114 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:106484 Archived-At: On Tue, Aug 11, 2015 at 04:39:45PM +0200, Pascal J. Bourguignon wrote: > Navy Cheng writes: > > > For example: > > > > (setq a 1) > > (setq b 2) > > (setq c 3) > > > > How can I a alist, like: > > How can you WHAT a alist? Sorry for that, (setq WHAT "create") > > > ((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))) > > This is not a valid form, because (a . 1) is not a function name, > therefore it's not possible to apply it. > Sorry again, (setq tree '((a . 1) (b . 2) (c .3))) > > If you want to BUILD an a-list, you can use acons: > > (let ((a 1) > (b 2) > (c 3)) > (let ((tree (acons 'a a (acons 'b b (acons 'c c '()))))) > tree)) > --> ((a . 1) (b . 2) (c . 3)) > Thanks for your patient and help. Your answer is OK. I have learned another way to do this. (setq tree `((a . ,a) (b . ,b) (c . ,c)))