Re: Is there something wrong with random function?
Sam Steingold <[email protected]> Thu, 16 Nov 2017 15:21:08 -0500
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <[email protected]> |
> * Jean Louis <[email protected]> [2017-11-16 20:22:05 +0300]: > > (defun random-number (&key (digits 6)) > "Returns the random number with 6 digits by default" > (setf *random-state* (make-random-state)) make-random-state is a relatively expensive function, calling it every time you need a random number is _not_ a good idea from any POV. > (let ((fstr (make-array '(0) :element-type 'base-char :fill-pointer 0 :adjustable t))) > (with-output-to-string (s fstr) > (dotimes (ti digits fstr) > (format s "~A" (random 10)))))) -- Sam Steingold (http://sds.podval.org/) on darwin Ns 10.3.1504 http://steingoldpsychology.com http://www.childpsy.net http://jij.org http://memri.org http://americancensorship.org Send $10 for a brochure on how to make money selling brochures. ------------------------------------------------------------------------------ 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