From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: PJ Weisberg Newsgroups: gmane.emacs.help Subject: Re: How to remove verbosity from the data passing mechanism using alist or plist ? Date: Mon, 6 Dec 2010 23:59:31 -0800 Message-ID: References: <87lj43at0i.fsf@ambire.localdomain> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1291708810 28541 80.91.229.12 (7 Dec 2010 08:00:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 7 Dec 2010 08:00:10 +0000 (UTC) To: help-gnu-emacs Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Dec 07 09:00:07 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PPsT0-0007Go-NC for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Dec 2010 09:00:06 +0100 Original-Received: from localhost ([127.0.0.1]:36481 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPsT0-0007zp-6j for geh-help-gnu-emacs@m.gmane.org; Tue, 07 Dec 2010 03:00:06 -0500 Original-Received: from [140.186.70.92] (port=51251 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PPsSY-0007za-88 for Help-gnu-emacs@gnu.org; Tue, 07 Dec 2010 02:59:39 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PPsSW-00009a-5C for Help-gnu-emacs@gnu.org; Tue, 07 Dec 2010 02:59:38 -0500 Original-Received: from smtpauth13.prod.mesa1.secureserver.net ([64.202.165.37]:45343) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1PPsSV-00009J-RG for Help-gnu-emacs@gnu.org; Tue, 07 Dec 2010 02:59:36 -0500 Original-Received: (qmail 16828 invoked from network); 7 Dec 2010 07:59:33 -0000 Original-Received: from unknown (74.125.82.169) by smtpauth13.prod.mesa1.secureserver.net (64.202.165.37) with ESMTP; 07 Dec 2010 07:59:33 -0000 Original-Received: by wyj26 with SMTP id 26so5883265wyj.0 for ; Mon, 06 Dec 2010 23:59:31 -0800 (PST) Original-Received: by 10.227.3.16 with SMTP id 16mr6893659wbl.223.1291708771567; Mon, 06 Dec 2010 23:59:31 -0800 (PST) Original-Received: by 10.227.147.140 with HTTP; Mon, 6 Dec 2010 23:59:31 -0800 (PST) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:75527 Archived-At: On Mon, Dec 6, 2010 at 10:18 PM, Fren Zeee wrote: >> =A0 [Q] Is there a way to avoid lengthy calling statement like >> =A0 =A0 =A0 =A0 (car (assoc-default :GOLD-value =A0 =A0GOLD ) >> =A0 =A0 =A0 inside let, >> >> =A0 =A0 =A0 since the first argument of let is an alist of the form >> =A0 =A0 =A0 =A0 =A0 =A0((sym1 val1) (sym2 val2)) >> > > OK lets take the suggestion below and show me how it works with my case ? > >> You need the =91car=92 because you do =91(list k v)=92. >> If you use =91(cons k v)=92, then you do not need the =91car=92. > > What I have is > > (list (list k1 v1) (list k2 v2)) > > Now, kindly show me where I put the car to get both of these uniformly > communicated outside of the function to another function ? Later in > some cases I may have (k3 v3) pair !!! Don't put the car anywhere. Change that to (list (cons k1 v1) (cons k2 v2)) and then use use (assoc-default k1 myList), (assoc-default k2 myList), etc. With that sexp you gave earlier, (assoc-default 'y '((w . 0) (x . 1) (y . 2) (z . 3))) Now it returns 2 instead of (2), so if you wanted the number you don't need car to get it. I think you were asking the difference between cons and list, and I was going to write some kind of explanation, but apparently the part of my brain that's capable of explaining things clearly has already gone to sleep, so before I turn in I'll just say that lisp uses linked lists with one "cons cell" for each item in the list, and those things that look like lists but have dots in them are a result of someone abusing "cons" to make a cons cell whose 'next' pointer points to something other than the next cons cell in a list.