next up previous

12.7.4 Random

The random function returns a "random" integer value. It is patterned after the ANSI standard rand library function and therefore may not be available on all platforms.

Syntax

(random)

Example

(defrule roll-the-dice
   (roll-the-dice)
   =>
   (bind ?roll1 (+ (mod (random) 6) 1))
   (bind ?roll2 (+ (mod (random) 6) 1))
   (printout t "Your roll is:  " ?roll1 " " ?roll2 crlf))

Portability Note

If the ANSI_COMPILER flag has not been set, this function compiles to a nonfunctional stub that always returns zero.


next up previous