Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.lisp > #60795
| Path | csiph.com!weretis.net!feeder9.news.weretis.net!border-3.nntp.ord.giganews.com!nntp.giganews.com!local-2.nntp.ord.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail |
|---|---|
| NNTP-Posting-Date | Mon, 01 Jun 2026 19:10:53 +0000 |
| From | steve g <sgonedes1977@gmail.com> |
| Newsgroups | comp.lang.lisp |
| Subject | Re: Make a random-state from a non-random source |
| References | <jwvmryfku8t.fsf-monnier+comp.lang.lisp@gnu.org> |
| Date | Mon, 01 Jun 2026 15:10:44 -0400 |
| Message-ID | <87h5nmule3.fsf@gmail.com> (permalink) |
| User-Agent | Gnus/5.13 (Gnus v5.13) |
| Cancel-Lock | sha1:nlKWHqKb3sGzXEYpQMvPTV2QH5g= |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Lines | 50 |
| X-Usenet-Provider | http://www.giganews.com |
| X-Trace | sv3-S0Lg6SAWAgN1MJvF9vyXKgMUpIftmUtMnNKluwOo4poDVbXajSFwXtUR+r8UbatxoQYgEuTZ4upghtZ!PejHwLewmhOK510oHZ6AeUg/m4WHxu4XZc4pIZ3FBt18gpg= |
| X-Complaints-To | abuse@giganews.com |
| X-DMCA-Notifications | http://www.giganews.com/info/dmca.html |
| X-Abuse-and-DMCA-Info | Please be sure to forward a copy of ALL headers |
| X-Abuse-and-DMCA-Info | Otherwise we will be unable to process your complaint properly |
| X-Postfilter | 1.3.40 |
| Xref | csiph.com comp.lang.lisp:60795 |
Show key headers only | View raw
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> Reading the CLHS about `make-random-state` I can't see how to create
> a "deterministic" random state.
>
> I want it to be deterministic in the sense that if I re-run my program
> (including after changing it a bit), I'll get the exact same sequence of
> random numbers.
> It's OK if the sequence is different when run on a different Lisp
> implementation, OTOH.
>
> I guess I could print a random state into a file and then read it back in,
> but that depends on internals, so it's doubly messy.
>
>
> === Stefan
(defun gensym (&optional (thing "G"))
"Creates a new uninterned symbol whose name is a prefix string (defaults
to \"G\"), followed by a decimal number. Thing, when supplied, will
alter the prefix if it is a string, or be used for the decimal number
if it is a number, of this symbol. The default value of the number is
the current value of *gensym-counter* which is incremented each time
it is used."
(multiple-value-bind (prefix int)
(if (integerp thing)
(values "G" thing)
(values thing (let ((old *gensym-counter*))
(setq *gensym-counter* (1+ old))
old)))
(make-symbol (%symbol-nameify prefix int))))
this is from sbcl symbol.lisp.
a very poor way of doing this would look like this...
(let ((*gensym-counter* 25))
(gensym "CNT"))
I do not recommend doing this with gentemp, at least with sbcl.
Hencefold the worst way to make a random symol..!
Back to comp.lang.lisp | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Make a random-state from a non-random source Stefan Monnier <monnier@iro.umontreal.ca> - 2026-05-04 12:46 -0400
Re: Make a random-state from a non-random source Alan Bawden <alan@csail.mit.edu> - 2026-05-05 00:45 -0400
Re: Make a random-state from a non-random source Stefan Monnier <monnier@iro.umontreal.ca> - 2026-05-05 16:03 -0400
Re: Make a random-state from a non-random source Kaz Kylheku <046-301-5902@kylheku.com> - 2026-06-04 23:45 +0000
Re: Make a random-state from a non-random source tfb <no_email@invalid.invalid> - 2026-05-09 18:20 +0000
Re: Make a random-state from a non-random source Stefan Monnier <monnier@iro.umontreal.ca> - 2026-05-11 11:23 -0400
Re: Make a random-state from a non-random source steve g <sgonedes1977@gmail.com> - 2026-06-01 15:10 -0400
Re: Make a random-state from a non-random source Lawrence D’Oliveiro <ldo@nz.invalid> - 2026-06-01 23:58 +0000
csiph-web