From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Teemu Likonen Newsgroups: gmane.emacs.help Subject: Re: `append' vs. `nconc' Date: Wed, 30 Dec 2015 18:37:13 +0200 Message-ID: <87lh8bgafa.fsf@mithlond.arda> References: <568164D8.6050700@ojkastl.de> <87io3iyr7t.fsf@debian.uxu> <87si2kezg1.fsf@mithlond.arda> <87a8osrlj4.fsf_-_@debian.uxu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" X-Trace: ger.gmane.org 1451493467 24981 80.91.229.3 (30 Dec 2015 16:37:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 30 Dec 2015 16:37:47 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Dec 30 17:37:36 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 1aEJkj-00087b-OX for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Dec 2015 17:37:33 +0100 Original-Received: from localhost ([::1]:52978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aEJkj-0003Ax-23 for geh-help-gnu-emacs@m.gmane.org; Wed, 30 Dec 2015 11:37:33 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aEJkY-0003Aq-0i for help-gnu-emacs@gnu.org; Wed, 30 Dec 2015 11:37:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aEJkU-0007Pb-KA for help-gnu-emacs@gnu.org; Wed, 30 Dec 2015 11:37:21 -0500 Original-Received: from mta-out1.inet.fi ([62.71.2.193]:39692 helo=johanna3.inet.fi) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aEJkU-0007PV-9D for help-gnu-emacs@gnu.org; Wed, 30 Dec 2015 11:37:18 -0500 RazorGate-KAS: Status: not_detected RazorGate-KAS: Rate: 0 RazorGate-KAS: Envelope from: RazorGate-KAS: Version: 5.5.3 RazorGate-KAS: LuaCore: 80 2014-11-10_18-01-23 260f8afb9361da3c7edfd3a8e3a4ca908191ad29 RazorGate-KAS: Lua profiles 69136 [Nov 12 2014] RazorGate-KAS: Method: none Original-Received: from mithlond.arda (84.251.143.106) by johanna3.inet.fi (9.0.002.03-2-gbe5d057) id 5678101B00C3769A for help-gnu-emacs@gnu.org; Wed, 30 Dec 2015 18:37:17 +0200 Original-Received: from dtw by mithlond.arda with local (Exim 4.84) (envelope-from ) id 1aEJkS-00046k-M6 for help-gnu-emacs@gnu.org; Wed, 30 Dec 2015 18:37:16 +0200 In-Reply-To: <87a8osrlj4.fsf_-_@debian.uxu> (Emanuel Berg's message of "Wed, 30 Dec 2015 16:41:51 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 62.71.2.193 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:108528 Archived-At: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Emanuel Berg [2015-12-30 16:41:51+01] wrote: > So what you are saying, if `append' is replaced by `nconc', the same > thing happens, only one less list has to be created? Given the following: (append list1 list2 list3 last) (nconc list1 list2 list3 last) APPEND copies LIST1, LIST2 and LIST3 but not LAST. All original lists remain untouched but LAST becomes part of the new list returned by APPEND. NCONC doesn't copy lists but modifies LIST1's, LIST2's and LIST3's last cons's CDR to point to the next list. NCONC returnes the joined list. Only LAST remains untouched. > I have several appends in my source, is there a rule-of-thumb when to > use `append' and when to use `nconc'? You can use NCONC if it's safe to modify the lists, that is, you know where the lists come from and know how they are used. Don't modify a list created with '(...). Use (list ...) instead. =2D-=20 /// Teemu Likonen - .-.. // // PGP: 4E10 55DC 84E9 DFF6 13D7 8557 719D 69D3 2453 9450 /// --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJWhAg8AAoJEHGdadMkU5RQsFIQAJ8qmwOb5fExfbuIB2K1wKOd VIKzisxORRqN0magygsTH252lEKy7O8Vpu2A+O99zIUwNrWZTAkwhhIDLrDNF4E3 vt/IwgsL6Gywrdy/hmXAhtxSyiFh5FqoihSP4G0gfHr8wbrReYeEvtNzSePMOov1 ClZ0WJoqg2gULoOrbcLDlOrdk7nqdxIYXrcygikOaVPXB4iVycLH5VUoKXDRNuog WxiBHA3JPMD+4apqr9WJziWoQ8+jLjGWGs48PlDOWydyDIirCFYNx5umxoSA1ZPL dstp7O/AptFCEebsX8CjrccNYwEOiVED1KNQdQz20rgMQXQI8sjFnDu/lsMcjolv mk9MUyMc0g+Z0XF5AwJIvLHu1DwSxJxK4ujiX8RyeRjXR0t18sty6OLozRMMFCfZ zgi3HBaEOC6YvfBGSsVOvQyfLjXQTx9S1ayJ8ctuO3rX5Mw8oFDXUZb8jgrSNiPC Z6MK3BFuGmkV3tQwYNtJGqCdaBrFPn/ErPHslOWA9SINHTb5FVO5gy/UkayFSvYF UQhQ5QDiT671jPLyWW1UehMJTJLbQEF5NiHw93jfb79w2oJFJZN/0cKgYSzQDX43 7PKjCXx2NL28eHdbl98sk3/TQD7/nzvnUcaBUjYGEJjq7c4aV8AZLfjE0l9lH4jL sDvbxtLb9GI0KJWxpPAH =eKPP -----END PGP SIGNATURE----- --=-=-=--