From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: alists Date: Thu, 27 Mar 2008 00:57:01 -0400 Organization: Symantec Message-ID: References: NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1206596503 7199 80.91.229.12 (27 Mar 2008 05:41:43 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Mar 2008 05:41:43 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 27 06:42:14 2008 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.50) id 1Jeks6-0000IX-ND for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Mar 2008 06:41:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JekrV-0003ZA-65 for geh-help-gnu-emacs@m.gmane.org; Thu, 27 Mar 2008 01:41:17 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!postnews.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Wed, 26 Mar 2008 23:57:01 -0500 Original-Newsgroups: gnu.emacs.help Mail-Copies-To: nobody User-Agent: MT-NewsWatcher/3.5.3b2 (Intel Mac OS X) X-Copies-To: never Original-Lines: 82 X-Usenet-Provider: http://www.giganews.com Original-NNTP-Posting-Host: 24.34.108.171 Original-X-Trace: sv3-FdodWkOSS682XQweg6iUawV7mlIdRgzvETQVXAlmyxaK3r9QsmZLfQw+EeZ4Y/3NcuXaum6H7pVMtAb!rtxrnRKLmF8TMLoGFRTfZpwkVvkuU6zXADhmx2Gk0rYbbBoUCfepAbP0WIyVEhg+5tV799rPW6n0!VNzezEtTaNS74o3pBlWc5DG4FYrdI/m5kkhReHA= Original-X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.37 Original-Xref: shelby.stanford.edu gnu.emacs.help:157361 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:52731 Archived-At: In article , David Roderick wrote: > Elisp 5.8 > -- Function: copy-alist alist > This function returns a two-level deep copy of ALIST: it creates a > new copy of each association, so that you can alter the > associations of the new alist without changing the old one. > > (setq needles-per-cluster > '((2 . ("Austrian Pine" "Red Pine")) > (3 . ("Pitch Pine")) > (5 . ("White Pine")))) > => > ((2 "Austrian Pine" "Red Pine") > (3 "Pitch Pine") > (5 "White Pine")) > > (setq copy (copy-alist needles-per-cluster)) > => > ((2 "Austrian Pine" "Red Pine") > (3 "Pitch Pine") > (5 "White Pine")) > > (eq needles-per-cluster copy) > => nil > (equal needles-per-cluster copy) > => t > (eq (car needles-per-cluster) (car copy)) > => nil > (cdr (car (cdr needles-per-cluster))) > => ("Pitch Pine") > > I don't understand how the cdr of one element in the alist in connected > with the next cons cell. > The first cons cell has a CDR of "Austrian Pine" "Red Pine". > In what way does this contain a reference to the next list (3.("Pitch > Pine"))? > Is there an outer level of a sequence happening? > Yes, an outer list. > So (2 . ("Austrian Pine" "Red Pine")) is actually the CAR of an outer > cons cell which has (3 . ("Pitch Pine")) as its CDR. > Is this correct? Correct. That outer cons cell is the alist itself. Its elements are the individual associations. > > 2.3.6.2 Dotted Pair Notation > ............................ > In dotted pair > notation, the list `(1 2 3)' is written as `(1 . (2 . (3 . nil)))' > > (car (cdr needles-per-cluster)) > is (3 . ("Pitch Pine")) Do you have a question here? > > ELISP can be HEAVY GOING > > Elisp 5.3 > -- Function: cdr cons-cell > This function returns the value referred to by the second slot of > the cons cell CONS-CELL. Expressed another way, this function > returns the CDR of CONS-CELL. > > As a special case, if CONS-CELL is `nil', then `cdr' is defined to > return `nil'; therefore, any list is a valid argument for `cdr'. > An error is signaled if the argument is not a cons cell or `nil'. > > (cdr '(a b c)) > => (b c) > (cdr '()) > => nil Again, what's your question? -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE don't copy me on replies, I'll read them in the group ***