Is there something wrong with random function?

Jean Louis <[email protected]> Wed, 15 Nov 2017 21:36:56 +0300
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
(defun random-number (&key (digits 6))
  "Returns the random number with 6 digits by default"
  (setf *random-state* (make-random-state))
  (let ((fstr (make-array '(0) :element-type 'base-char :fill-pointer 0 :adjustable t)))
    (with-output-to-string (s fstr)
      (dotimes (ti digits)
        (princ (character (write-to-string (random 10))) s)))
    (read-from-string fstr)))

(dotimes (a 100) (print (random-number)))

My problem is that instead of expected number of
digits I am getting some results with less digits.

If somebody may point me what I am doing wrong here?

Jean

450077 
778443 
182907 
839769 
833192 
165307 
495888 
21293 
381081 
308108 
569634 
912337 
378310 
375199 
746300 
653187 
830890 
453431 
715230 
243971 
904868 
430667 
949359 
547176 
230287 
477169 
533133 
989289 
742708 
536445 
463811 
496006 
667320 
559498 
892674 
81845 
131499 
980561 
265818 
257092 
614642 
765861 
786298 
152150 
125145 
652729 
253214 
113316 
69502 
969609 
83573 
51141 
580459 
860885 
885101 
143923 
324844 
999906 
509298 
589387 
404468 
369613 
294785 
860850 
506745 
960909 
208242 
211930 
886300 
482334 
740116 
717921 
869410 
701807 
291191 
738314 
140958 
127689 
765440 
781315 
393983 
110850 
807583 
633602 
638934 
878229 
805056 
243313 
85297 
29936 
298996 
578113 
183051 
675424 
577537 
621787 
515388 
782140 
80778 
211632 
NIL


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list