unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* About elisp, Lossing data after sort
@ 2007-03-14  1:51 htbest2000
  2007-03-14  4:39 ` Barry Margolin
  0 siblings, 1 reply; 8+ messages in thread
From: htbest2000 @ 2007-03-14  1:51 UTC (permalink / raw)
  To: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-03-15 17:21 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-14  1:51 About elisp, Lossing data after sort htbest2000
2007-03-14  4:39 ` Barry Margolin
2007-03-14  5:24   ` htbest2000
2007-03-14  8:48     ` Pascal Bourguignon
2007-03-15 13:07       ` htbest2000
2007-03-15 17:21         ` Joost Kremers
2007-03-14  5:25   ` htbest2000
2007-03-14  5:25   ` htbest2000

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).