[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: About elisp, Lossing data after sort
From: |
htbest2000 |
Subject: |
Re: About elisp, Lossing data after sort |
Date: |
13 Mar 2007 22:24:32 -0700 |
User-agent: |
G2/1.0 |
On Mar 14, 12:39 pm, Barry Margolin <bar...@alum.mit.edu> wrote:
> In article <1173837100.827152.92...@l75g2000hse.googlegroups.com>,
>
>
>
> "htbest2000" <htbest2...@gmail.com> 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!