From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: some more material on the Lisp data/code psychedelia Date: Sat, 04 Jan 2014 21:13:26 +0100 Message-ID: <87ob3rpkt5.fsf@zigzag.favinet> References: <87sit31qt7.fsf@nl106-137-194.student.uu.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1388866218 9337 80.91.229.3 (4 Jan 2014 20:10:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 4 Jan 2014 20:10:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sat Jan 04 21:10:24 2014 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 1VzXY8-0000er-DQ for geh-help-gnu-emacs@m.gmane.org; Sat, 04 Jan 2014 21:10:24 +0100 Original-Received: from localhost ([::1]:55608 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzXY7-0008C5-VE for geh-help-gnu-emacs@m.gmane.org; Sat, 04 Jan 2014 15:10:23 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzXXe-0007ks-6t for help-gnu-emacs@gnu.org; Sat, 04 Jan 2014 15:09:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VzXXY-0002BA-DL for help-gnu-emacs@gnu.org; Sat, 04 Jan 2014 15:09:54 -0500 Original-Received: from smtp206.alice.it ([82.57.200.102]:51398) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VzXXY-0002B2-2l for help-gnu-emacs@gnu.org; Sat, 04 Jan 2014 15:09:48 -0500 Original-Received: from zigzag.favinet (79.54.70.96) by smtp206.alice.it (8.6.060.28) id 529A678F07291AE0 for help-gnu-emacs@gnu.org; Sat, 4 Jan 2014 21:09:46 +0100 Original-Received: from ttn by zigzag.favinet with local (Exim 4.80) (envelope-from ) id 1VzXbE-0001Fo-07 for help-gnu-emacs@gnu.org; Sat, 04 Jan 2014 21:13:36 +0100 Mail-Followup-To: help-gnu-emacs@gnu.org In-Reply-To: <87sit31qt7.fsf@nl106-137-194.student.uu.se> (Emanuel Berg's message of "Sat, 04 Jan 2014 20:37:15 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 82.57.200.102 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:95250 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable () Emanuel Berg () Sat, 04 Jan 2014 20:37:15 +0100 (defun increment-last (l) (interactive) (if (not l) '() (let ((hd (car l)) (tl (cdr l)) ) (if (not tl) (list (+ 1 hd)) (cons hd (increment-last tl) ))))) You can also use =E2=80=98last=E2=80=99 and =E2=80=98setcar=E2=80=99 (via = =E2=80=98incf=E2=80=99) for this: (defun increment-last (ls)=20 (when ls=20 (incf (car (last ls))) ls)) Non-recursive means less stack required for long forms. Destructive style is sketchy but the func is already squarely in DWR territory... =2D-=20 Thien-Thi Nguyen GPG key: 4C807502 (if you're human and you know it) read my lisp: (responsep (questions 'technical) (not (via 'mailing-list))) =3D> nil --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAlLIa2kACgkQZwMiJEyAdQJu6ACfTBQIsZPixmhDt9rkuVv5Xc2P DyEAoMeTwlP4Zw0fFzHS5cfrsxWOQNiA =O1xS -----END PGP SIGNATURE----- --=-=-=--