Hi there,
is the (random)-implementation in CLISP non-standard? I use the current
cygwin CLISP (v2.33.1), and the CLHS example:
(setq snap-shot (make-random-state))
;; The series from any given point is random,
;; but if you backtrack to that point, you get the same series.
(list (loop for i from 1 to 10 collect (random))
(let ((*random-state* snap-shot))
(loop for i from 1 to 10 collect (random)))
(loop for i from 1 to 10 collect (random))
(let ((*random-state* snap-shot))
(loop for i from 1 to 10 collect (random))))
fails with an error saying random needs more parameters.
Thanks,
Dirk
Dirk Bernhardt <······@krid.de> writes:
> Hi there,
>
> is the (random)-implementation in CLISP non-standard? I use the
> current cygwin CLISP (v2.33.1), and the CLHS example:
>
> (setq snap-shot (make-random-state))
> ;; The series from any given point is random,
> ;; but if you backtrack to that point, you get the same series.
> (list (loop for i from 1 to 10 collect (random))
> (let ((*random-state* snap-shot))
> (loop for i from 1 to 10 collect (random)))
> (loop for i from 1 to 10 collect (random))
> (let ((*random-state* snap-shot))
> (loop for i from 1 to 10 collect (random))))
>
> fails with an error saying random needs more parameters.
The error message seems right--per the CHS you must supply at least
one argument--the limit. It also takes a random state object as a
second, optional, argument. (Hmmm. Looks like the example in the
*RANDOM-STATE* dictionary entry is busted. Try adding an argument such
as 100 to all the calls to RANDOM.
-Peter
--
Peter Seibel ·····@javamonkey.com
Lisp is the red pill. -- John Fraser, comp.lang.lisp
Dirk Bernhardt wrote:
> is the (random)-implementation in CLISP non-standard? I use the current
> cygwin CLISP (v2.33.1), and the CLHS example:
Nevermind, the example in CLHS is wrong. random needs a parameter, and
thus works:
(setq snap-shot (make-random-state))
;; The series from any given point is random,
;; but if you backtrack to that point, you get the same series.
(list (loop for i from 1 to 10 collect (random 1000))
(let ((*random-state* snap-shot))
(loop for i from 1 to 10 collect (random 1000)))
(loop for i from 1 to 10 collect (random 1000))
(let ((*random-state* snap-shot))
(loop for i from 1 to 10 collect (random 1000))))
Cheers,
Dirk