[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: beginnerquestion (nconc)

From: Thien-Thi Nguyen
Subject: Re: beginnerquestion (nconc)
Date: Fri, 17 Mar 2017 08:33:13 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

() 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

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:

  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: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]