From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: About elisp, Lossing data after sort Date: Wed, 14 Mar 2007 00:39:08 -0400 Organization: Symantec Message-ID: References: <1173837100.827152.92620@l75g2000hse.googlegroups.com> NNTP-Posting-Host: lo.gmane.org X-Trace: sea.gmane.org 1173847184 22564 80.91.229.12 (14 Mar 2007 04:39:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 14 Mar 2007 04:39:44 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Mar 14 05:39:38 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HRLGz-0008T4-LN for geh-help-gnu-emacs@m.gmane.org; Wed, 14 Mar 2007 05:39:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HRLHp-0007nd-Ry for geh-help-gnu-emacs@m.gmane.org; Tue, 13 Mar 2007 23:40:29 -0500 Original-Path: shelby.stanford.edu!newshub.stanford.edu!postnews.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail Original-NNTP-Posting-Date: Tue, 13 Mar 2007 23:39:09 -0500 Original-Newsgroups: gnu.emacs.help Mail-Copies-To: nobody User-Agent: MT-NewsWatcher/3.5.2 (PPC Mac OS X) X-Copies-To: never Original-Lines: 50 Original-NNTP-Posting-Host: 24.34.108.171 Original-X-Trace: sv3-aEepFwadMoPUkcJSLGBsZicQ6qQnGRuTV75/y0Fis3tuuK+8Clqe0T3DZ1p/fmEFh3OOe6VMaaMw7A2!ZorpJOaJ2cLjI4p7L/sE1Lk+N2d2EjvdAQvZWOFOkSvPid2nQOpP/K9WcUwNRWo3xHckf3nISTiB!AGHqQlEP+MrFowZ2so8/QIFN2rLedBTrRP77nQ/hLg== Original-X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.34 Original-Xref: shelby.stanford.edu gnu.emacs.help:146342 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:41946 Archived-At: In article <1173837100.827152.92620@l75g2000hse.googlegroups.com>, "htbest2000" wrote: > Hi, > > I am using "GNU Emacs 22.0.94.1 (i386-mingw-nt5.0.2195) of > 2007-02-24 on NEUTRINO" > > I'm writting a function to generate a series of random numbers, > it seems work fine alone. But the data always lost after sort, > following is the code: > > > (defun random-list (n) > "return a list with random numbers from [0,N), length of N" > (let ((i 0) (list nil)) > (while (< i n) > (progn (setq list (cons (random n) list)) > (setq i (+ 1 i)))) > list)) > > (defun main (n) > "program entry" > (let ((list nil)) > (setq list (random-list n)) > (princ (format "%S\n" list)) ;print list > (sort list '<) Change that to: (setq list (sort list '<)) > (princ (format "%S\n" list)) ;print same again > nil > )) > > > For example, running: (main 10) > > the result: > (9 2 8 4 7 8 1 1 9 3) > (9 9) > > What's wrong in my code? Thanks -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***