[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

About elisp, Lossing data after sort

From: htbest2000
Subject: About elisp, Lossing data after sort
Date: 13 Mar 2007 18:51:40 -0700
User-agent: G2/1.0


I am using "GNU Emacs (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))))

(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

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]