Random number generator (included): Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
Hendursaga (talk | contribs) m (Fix incorrect function name, remove incorrect notice, & add note.) |
||
Line 208: | Line 208: | ||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
{{incorrect|Common Lisp|Use CLHS as reference. Function rand is incorrect it should be random .}} |
|||
The easiest way to generate random numbers in Common Lisp is to use the built-in rand function after seeding the random number generator. For example, the first line seeds the random number generator and the second line generates a number from 0 to 9 |
The easiest way to generate random numbers in Common Lisp is to use the built-in rand function after seeding the random number generator. For example, the first line seeds the random number generator and the second line generates a number from 0 to 9 |
||
<syntaxhighlight lang="lisp">(setf *random-state* (make-random-state t)) |
<syntaxhighlight lang="lisp">(setf *random-state* (make-random-state t)) |
||
( |
(random 10)</syntaxhighlight> |
||
[https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node133.html Common Lisp: The Language, 2nd Ed.] does not specify a specific random number generator algorithm. |
[https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node133.html Common Lisp: The Language, 2nd Ed.] does not specify a specific random number generator algorithm, nor a way to use a user-specified seed. |
||
=={{header|D}}== |
=={{header|D}}== |