From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Thien-Thi Nguyen Newsgroups: gmane.emacs.help Subject: Re: beginnerquestion (nconc) Date: Fri, 17 Mar 2017 08:33:13 +0100 Message-ID: <87tw6sjr2e.fsf@zigzag.favinet> References: <87shmc1m2u.fsf@mail.de> Reply-To: help-gnu-emacs@gnu.org NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" X-Trace: blaine.gmane.org 1489736379 19217 195.159.176.226 (17 Mar 2017 07:39:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 17 Mar 2017 07:39:39 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) Cc: Stefan Huchler To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Mar 17 08:39:33 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1comTx-0003zX-FC for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Mar 2017 08:39:29 +0100 Original-Received: from localhost ([::1]:47547 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1comU3-0007FV-Kt for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Mar 2017 03:39:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51001) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1comTc-0007FA-FW for help-gnu-emacs@gnu.org; Fri, 17 Mar 2017 03:39:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1comTZ-0003Oe-Cn for help-gnu-emacs@gnu.org; Fri, 17 Mar 2017 03:39:08 -0400 Original-Received: from mail.agora-net.com ([67.59.132.6]:54000) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1comTZ-0003Mo-7z for help-gnu-emacs@gnu.org; Fri, 17 Mar 2017 03:39:05 -0400 Original-Received: from ttn by mail.agora-net.com with local (Exim 4.82) (envelope-from ) id 1comTW-0006Dy-PT; Fri, 17 Mar 2017 03:39:02 -0400 Original-Received: from ttn by zigzag.favinet with local (Exim 4.80) (envelope-from ) id 1comO4-0007kj-0G; Fri, 17 Mar 2017 08:33:24 +0100 Mail-Followup-To: help-gnu-emacs@gnu.org In-Reply-To: <87shmc1m2u.fsf@mail.de> (Stefan Huchler's message of "Fri, 17 Mar 2017 06:58:17 +0100") X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: ttn@gnuvola.org X-SA-Exim-Scanned: No (on mail.agora-net.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 67.59.132.6 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.help:112585 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable () Stefan Huchler () Fri, 17 Mar 2017 06:58:17 +0100 I found in the doku the nconc macro, which looks like some sort of push that puts sequences at the end instead of the beginning. Was that documentation by any chance "(elisp) Rearrangement"? That info node describes "A common pitfall...". Personally, these days i prefer =E2=80=98cl-loop=E2=80=99 for non-trivial s= tuff: (cl-loop for n below 5 collect (intern (string (+ ?a n)))) =3D> (a b c d e) If you MUST use =E2=80=98nconc=E2=80=99, a common trick is to init the var = w/ a throwaway head, to be ignored (afterwards) via =E2=80=98(cdr var)=E2=80=99. (setq test3 (list 'MGMT)) ; overhead? underfoot? both? :-D (nconc test3 (list '(a))) (nconc test3 (list '(b))) (cdr test3) =3D> ((a) (b)) This example takes care to avoid quoted literals for the init and top-level cons'ed objects. I also dropped =E2=80=98print=E2=80=99 beca= use that happens automagically in the *scratch* buffer. BTW, =E2=80=98nconc=E2=80=99 is not a macro. I see this from =E2=80=98C-h = f nconc RET=E2=80=99. =2D-=20 Thien-Thi Nguyen ----------------------------------------------- (defun responsep (query) (pcase (context query) (`(technical ,ml) (correctp ml)) ...)) 748E A0E8 1CB8 A748 9BFA =2D-------------------------------------- 6CE4 6703 2224 4C80 7502 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAljLkTwACgkQZwMiJEyAdQI9uACgiS+KYlU1vQRYd0WybpD1S9/e cFAAoJqbxywYhQdhgpAKP9ujA48ZVVbf =LCt6 -----END PGP SIGNATURE----- --=-=-=--