From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Huchler Newsgroups: gmane.emacs.help Subject: beginnerquestion (nconc) Date: Fri, 17 Mar 2017 06:58:17 +0100 Message-ID: <87shmc1m2u.fsf@mail.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1489730362 22084 195.159.176.226 (17 Mar 2017 05:59:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 17 Mar 2017 05:59:22 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) 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 06:59:17 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 1cokuw-0004ym-Gp for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Mar 2017 06:59:14 +0100 Original-Received: from localhost ([::1]:47263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cokv2-0003kW-K3 for geh-help-gnu-emacs@m.gmane.org; Fri, 17 Mar 2017 01:59:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:55198) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cokua-0003kE-GL for help-gnu-emacs@gnu.org; Fri, 17 Mar 2017 01:58:53 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cokuV-0002T2-MA for help-gnu-emacs@gnu.org; Fri, 17 Mar 2017 01:58:52 -0400 Original-Received: from [195.159.176.226] (port=49874 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cokuV-0002SS-ER for help-gnu-emacs@gnu.org; Fri, 17 Mar 2017 01:58:47 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1cokuI-0000y3-8h for help-gnu-emacs@gnu.org; Fri, 17 Mar 2017 06:58:34 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 34 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:2tE0sN+rjjwhYlbTUieL9NDssMI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:112584 Archived-At: Hello, I am a bit anoyed by push and reverse lists its not very straightforward solution to create lists in loops, 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. So I tried to use it instead of push but it behaves strange, it only works with nonempty lists: Code to replace: (setq test '()) (push '(a) test) (push '(b) test) (print (reverse test)) What I would expect to work: (setq test2 '()) (nconc test2 '((a))) (nconc test2 '((b))) (print test2) But only if I setq test2 the value of the first nconc expression it works. Which is ok for that example but does not work very well in a loop. Is there a trick or another expression/macro that does what I want? I guess there is add-to-list but it removes equal elements what I dont want. Thank you.