From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "htbest2000" Newsgroups: gmane.emacs.help Subject: About elisp, Lossing data after sort Date: 13 Mar 2007 18:51:40 -0700 Organization: http://groups.google.com Message-ID: <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 1173839981 7168 80.91.229.12 (14 Mar 2007 02:39:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 14 Mar 2007 02:39:41 +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 03:39:35 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 1HRJOo-0005zQ-Qg for geh-help-gnu-emacs@m.gmane.org; Wed, 14 Mar 2007 03:39:35 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HRJPe-0006TM-GL for geh-help-gnu-emacs@m.gmane.org; Tue, 13 Mar 2007 21:40:26 -0500 Original-Path: shelby.stanford.edu!newshub.stanford.edu!postnews.google.com!l75g2000hse.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 37 Original-NNTP-Posting-Host: 61.48.25.165 Original-X-Trace: posting.google.com 1173837102 27563 127.0.0.1 (14 Mar 2007 01:51:42 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Wed, 14 Mar 2007 01:51:42 +0000 (UTC) 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: l75g2000hse.googlegroups.com; posting-host=61.48.25.165; posting-account=O_8QnQ0AAADIZZO7k2o5s1xinXEvZp9l Original-Xref: shelby.stanford.edu gnu.emacs.help:146341 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:41945 Archived-At: 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 '<) (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