From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marcin Borkowski Newsgroups: gmane.emacs.help Subject: Is this use of nreverse a good practice? Date: Sun, 01 Feb 2015 13:08:17 +0100 Message-ID: <878ughn8b2.fsf@wmi.amu.edu.pl> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1422792530 31789 80.91.229.3 (1 Feb 2015 12:08:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 1 Feb 2015 12:08:50 +0000 (UTC) To: Help Gnu Emacs mailing list Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Feb 01 13:08:50 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 1YHtKb-0007nd-9i for geh-help-gnu-emacs@m.gmane.org; Sun, 01 Feb 2015 13:08:49 +0100 Original-Received: from localhost ([::1]:50176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHtKa-0008JX-Gs for geh-help-gnu-emacs@m.gmane.org; Sun, 01 Feb 2015 07:08:48 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHtKQ-0008JR-2X for help-gnu-emacs@gnu.org; Sun, 01 Feb 2015 07:08:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YHtKJ-0005W2-Mm for help-gnu-emacs@gnu.org; Sun, 01 Feb 2015 07:08:38 -0500 Original-Received: from msg.wmi.amu.edu.pl ([2001:808:114:2::50]:34913) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YHtKJ-0005VP-GH for help-gnu-emacs@gnu.org; Sun, 01 Feb 2015 07:08:31 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by msg.wmi.amu.edu.pl (Postfix) with ESMTP id 9F5B24C304 for ; Sun, 1 Feb 2015 13:08:27 +0100 (CET) Original-Received: from msg.wmi.amu.edu.pl ([127.0.0.1]) by localhost (msg.wmi.amu.edu.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cDyHl9AYy3zt for ; Sun, 1 Feb 2015 13:08:27 +0100 (CET) Original-Received: from localhost (117-116.echostar.pl [213.156.117.116]) by msg.wmi.amu.edu.pl (Postfix) with ESMTPSA id 4908D4C303 for ; Sun, 1 Feb 2015 13:08:27 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:808:114:2::50 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:102418 Archived-At: Hi there, I'm writing a small function which should build a list and return it. What I'm doing is more or less this: (defun myfunc () (let ((list-var)) (while CONDITION (DO-SOMETHING) (push SOME-ELEMENT list-var)) (nreverse list-var))) A more concrete example: (defun reverse-range (n) (let ((list-var)) (while (> n 0) (push n list-var) (decf n)) (nreverse list-var))) (reverse-range 5) =E2=87=92 (5 4 3 2 1) Is this usage of `nreverse' correct? I guess it is, since list-var is only a temporary variable and destructing it doesn't bother me. However, I'm never sure I'm doing things right when using nconc/nreverse, so I though I'd better ask... TIA, --=20 Marcin Borkowski http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski Faculty of Mathematics and Computer Science Adam Mickiewicz University