From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.devel Subject: Re: Add hints to documentation of car and cdr for (e)lisp newcomers - take 2 Date: Wed, 14 Jul 2021 17:48:47 +0200 Message-ID: <20210714154847.GA17354@tuxteam.de> References: <8735shrl57.fsf@tullinup.koldfront.dk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7JfCtLOvnd9MIVvH" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22980"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.5.21 (2010-09-15) Cc: emacs-devel@gnu.org To: Adam =?utf-8?Q?Sj=C3=B8gren?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jul 14 17:49:52 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3h8y-0005hT-H8 for ged-emacs-devel@m.gmane-mx.org; Wed, 14 Jul 2021 17:49:52 +0200 Original-Received: from localhost ([::1]:40814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3h8x-0007C6-33 for ged-emacs-devel@m.gmane-mx.org; Wed, 14 Jul 2021 11:49:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59360) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3h7z-0006VX-OZ for emacs-devel@gnu.org; Wed, 14 Jul 2021 11:48:51 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:59398) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.90_1) (envelope-from ) id 1m3h7x-00062M-Q3 for emacs-devel@gnu.org; Wed, 14 Jul 2021 11:48:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:Date; bh=l0nbBJQ3ZJ9lPSvuw8I8DwmHzqXjN7io2n/17e2KK+I=; b=AJuRi5oA5jpG0iHhifIk0P7M1+rn/8InHsB2dNiLAIyEMIV19yBsXhlnu5q0SE8ROv3Ou1eFQgDpyNR1/Q2CHpgLnigTtXtFm2IvzA15vileNT8LtvPFaYycG3iD3ldjM7KPMkcSJzRq/mcl+cGeojmsJMEU2Cxmq5eWaTllP4a7k+/+AtxofYOmmFx+/lfcykBG6U6o+xx1qLFzq2eaLe1R5vJWajWe0FJ5LGccLCiaRkpX1aAcwOrdpBuV7mnFTsxTOt12MOOOGeiBz6D/jEYN776p4MOSRZCQa5hmQ+SrnfWOIYb3aQ1aMqCDZTAv5QF1i52F6WHZtSyVmjCAMg==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1m3h7v-0004ca-Cj; Wed, 14 Jul 2021 17:48:47 +0200 Content-Disposition: inline In-Reply-To: <8735shrl57.fsf@tullinup.koldfront.dk> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271216 Archived-At: --7JfCtLOvnd9MIVvH Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 14, 2021 at 05:05:24PM +0200, Adam Sj=C3=B8gren wrote: > Ten years ago I was confused by the documentation of car and cdr: >=20 > ,---- > | (car LIST) > |=20 > | Return the car of LIST. If arg is nil, return nil. > `---- >=20 > ,---- > | (cdr LIST) > |=20 > | Return the cdr of LIST. If arg is nil, return nil. > `---- Yes, this is quite a bit of LISP lore, which is based on how lists are built of pairs. You have to keep those two concepts apart... > Or what about: >=20 > ,---- > | (car LIST) > |=20 > | Return the car of LIST, eg if LIST is '(a . b) return a. If arg is n= il, return nil. > `---- >=20 > ,---- > | (cdr LIST) > |=20 > | Return the cdr of LIST, eg if LIST is '(a . b) return b. If arg is n= il, return nil. > `---- =2E.. this, for example, doesn't exactly work: '(a . b) is not a (proper) l= ist (unless b is a list itself). I think there's no way around drawing some box-and-pointer diagrams yoursel= f. If you are focusing on lists, perhaps the best way to view this is that the car is the first element of the list and the cdr is the rest of the list: (car '(a b c d e)) =3D> 'a (cdr '(a b c d e)) =3D> '(b c d e) Now I don't know where your issue is. Is it the mnemonics for `car' and `cd= r'? Or the lack of a more thorough introduction on how lists are built of pairs? Cheers - t --7JfCtLOvnd9MIVvH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAmDvB18ACgkQBcgs9XrR2kZGywCfT51MzQfAUgHd0JHuL+VIlY7T Vp8AnRM3/vxJNUIaTmHH+O34TygMIVmd =V1iu -----END PGP SIGNATURE----- --7JfCtLOvnd9MIVvH--