Movatterモバイル変換


[0]ホーム

URL:


[LISPWORKS][Common Lisp HyperSpec (TM)][Previous][Up][Next]


FunctionRANDOM

Syntax:

randomlimit&optional random-state =>random-number

Arguments and Values:

limit---a positiveinteger, or a positivefloat.

random-state---arandom state. The default is thecurrent random state.

random-number---a non-negativenumber less thanlimit and of the sametype aslimit.

Description:

Returns a pseudo-random number that is a non-negativenumber less thanlimit and of the sametype aslimit.

Therandom-state, which is modified by this function, encodes the internal state maintained by the random number generator.

An approximately uniform choice distribution is used. Iflimit is aninteger, each of the possible results occurs with (approximate) probability 1/limit.

Examples:

 (<= 0 (random 1000) 1000) =>true (let ((state1 (make-random-state))       (state2 (make-random-state)))   (= (random 1000 state1) (random 1000 state2))) =>true

Side Effects:

Therandom-state is modified.

Affected By: None.

Exceptional Situations:

Should signal an error oftypetype-error iflimit is not a positiveinteger or a positivereal.

See Also:

make-random-state,*random-state*

Notes:

SeeCommon Lisp: The Language for information about generating random numbers.


[Starting Points][Contents][Index][Symbols][Glossary][Issues]
Copyright 1996-2005, LispWorks Ltd. All rights reserved.


[8]ページ先頭

©2009-2025 Movatter.jp