From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ian Zimmerman Newsgroups: gmane.emacs.help Subject: Re: How to use a symbol and its value to create alist? Date: Tue, 11 Aug 2015 08:21:53 -0700 Message-ID: <20150811151533.17219.21BE0C0D@ahiker.mooo.com> References: <20150811135254.GA20200@debian> Reply-To: help-gnu-emacs@gnu.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1439306531 27429 80.91.229.3 (11 Aug 2015 15:22:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 11 Aug 2015 15:22:11 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Aug 11 17:22:11 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 1ZPBNS-0006Ew-19 for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Aug 2015 17:22:10 +0200 Original-Received: from localhost ([::1]:34864 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPBNR-0003ZX-AQ for geh-help-gnu-emacs@m.gmane.org; Tue, 11 Aug 2015 11:22:09 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPBNF-0003XY-G2 for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 11:21:58 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZPBNE-0001dz-Lj for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 11:21:57 -0400 Original-Received: from disorder-1-pt.tunnel.tserv3.fmt2.ipv6.he.net ([2001:470:1f04:51a::2]:38013 helo=acedia.primate.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZPBNE-0001dM-CQ for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 11:21:56 -0400 Original-Received: from acedia.primate.net (localhost [127.0.0.1]) by acedia.primate.net (8.14.9/8.14.9/Debian-4) with ESMTP id t7BFLrMB013663 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 11 Aug 2015 08:21:53 -0700 Original-Received: (from itz@localhost) by acedia.primate.net (8.14.9/8.14.9/Submit) id t7BFLrxo013657 for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 08:21:53 -0700 X-Authentication-Warning: acedia.primate.net: itz set sender to itz@buug.org using -f Original-Received: from itz by ahiker.mooo.com with local (Exim 4.80) (envelope-from ) id 1ZPBNB-0004V8-AL for help-gnu-emacs@gnu.org; Tue, 11 Aug 2015 08:21:53 -0700 Content-Disposition: inline In-Reply-To: <20150811135254.GA20200@debian> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:470:1f04:51a::2 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:106468 Archived-At: 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.