From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "htbest2000" Newsgroups: gmane.emacs.help Subject: Re: About elisp, Lossing data after sort Date: 13 Mar 2007 22:24:32 -0700 Organization: http://groups.google.com Message-ID: <1173849872.137952.101020@b75g2000hsg.googlegroups.com> References: <1173837100.827152.92620@l75g2000hse.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: sea.gmane.org 1173850798 30547 80.91.229.12 (14 Mar 2007 05:39:58 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 14 Mar 2007 05:39:58 +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 06:39:52 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 1HRMDG-0006s7-38 for geh-help-gnu-emacs@m.gmane.org; Wed, 14 Mar 2007 06:39:50 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HRME5-0004AH-Mb for geh-help-gnu-emacs@m.gmane.org; Wed, 14 Mar 2007 00:40:41 -0500 Original-Path: shelby.stanford.edu!newshub.stanford.edu!postnews.google.com!b75g2000hsg.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 54 Original-NNTP-Posting-Host: 221.219.255.127 Original-X-Trace: posting.google.com 1173849873 28078 127.0.0.1 (14 Mar 2007 05:24:33 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 14 Mar 2007 05:24:33 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.0; zh-CN; rv:1.8.1) Gecko/20061010 Firefox/2.0,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: b75g2000hsg.googlegroups.com; posting-host=221.219.255.127; posting-account=O_8QnQ0AAADIZZO7k2o5s1xinXEvZp9l Original-Xref: shelby.stanford.edu gnu.emacs.help:146343 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:41947 Archived-At: On Mar 14, 12:39 pm, Barry Margolin wrote: > In article <1173837100.827152.92...@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, bar...@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 *** Thanks in advance!