all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thien-Thi Nguyen <ttn@gnu.org>
To: help-gnu-emacs@gnu.org
Cc: Stefan Huchler <stefan.huchler@mail.de>
Subject: Re: beginnerquestion (nconc)
Date: Fri, 17 Mar 2017 08:33:13 +0100	[thread overview]
Message-ID: <87tw6sjr2e.fsf@zigzag.favinet> (raw)
In-Reply-To: <87shmc1m2u.fsf@mail.de> (Stefan Huchler's message of "Fri, 17 Mar 2017 06:58:17 +0100")

[-- Attachment #1: Type: text/plain, Size: 1351 bytes --]


() Stefan Huchler <stefan.huchler@mail.de>
() 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 ‘cl-loop’ for non-trivial stuff:

 (cl-loop
  for n below 5
  collect (intern (string (+ ?a n))))

 => (a b c d e)

If you MUST use ‘nconc’, a common trick is to init the var w/ a
throwaway head, to be ignored (afterwards) via ‘(cdr var)’.

 (setq test3 (list 'MGMT))  ; overhead?  underfoot?  both?  :-D
 (nconc test3 (list '(a)))
 (nconc test3 (list '(b)))
 (cdr test3)

 => ((a) (b))

This example takes care to avoid quoted literals for the init
and top-level cons'ed objects.  I also dropped ‘print’ because
that happens automagically in the *scratch* buffer.

BTW, ‘nconc’ is not a macro.  I see this from ‘C-h f nconc RET’.

-- 
Thien-Thi Nguyen -----------------------------------------------
 (defun responsep (query)
   (pcase (context query)
     (`(technical ,ml) (correctp ml))
     ...))                              748E A0E8 1CB8 A748 9BFA
--------------------------------------- 6CE4 6703 2224 4C80 7502


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2017-03-17  7:33 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17  5:58 beginnerquestion (nconc) Stefan Huchler
2017-03-17  7:33 ` Thien-Thi Nguyen [this message]
2017-03-17  8:52   ` Thien-Thi Nguyen
2017-03-17 14:19   ` Stefan Huchler
2017-03-17 14:48     ` tomas
2017-03-17 14:42 ` Yuri Khan
2017-03-17 16:59   ` Stefan Huchler
2017-03-17 17:20     ` Drew Adams
2017-03-17 17:32       ` Drew Adams
2017-03-18  2:15     ` Stefan Monnier
2017-03-21 16:47       ` Stefan Huchler
2017-03-21 16:59       ` Stefan Huchler
2017-03-21 20:14         ` John Mastro
2017-03-22  0:32           ` Stefan Huchler
2017-03-22 15:02             ` Michael Heerdegen
2017-03-22 19:00             ` John Mastro
2017-03-21 11:05     ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tw6sjr2e.fsf@zigzag.favinet \
    --to=ttn@gnu.org \
    --cc=help-gnu-emacs@gnu.org \
    --cc=stefan.huchler@mail.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.