random [Pattern]

Enumerates items in random order. The probability of an item being selected may be altered by weighting items relative to one another and by constraining the minimum and maximum number of times an item may be consecutively selected. By default, each item in the pattern has an equal probability of selection and may be repeated in direct succession any number of times. To qualify the behavior of an element, specify the item in a list together with its qualifying options:

({item} {option value}*) item is the element to return from the pattern. Following item comes zero or more options value pairs. Each option may be specified using either keyword or symbol form:

weight {number | stream}
Sets number be the probability of the element relative to the weights of the other items. The default weight for each element is 1. weight may be also an item stream of numbers, in which case a weighting factor for the element will be selected each new period in the pattern.
min {number}
Sets a floor (low value) on how many direct repetitions the element must be made before a new element might be selected.
max {number}
Sets a ceiling on how many direct repetitions of the element might be made before a new element must be selected.
random implements the following option value pairs:

using {random-state}
Sets the random-state object of the stream, which default to *cm-state*.

Example:

? (setf x (notes c4 d (e weight 3) f g in random))
#<RANDOM-NOTE-STREAM 140173561>

? (read-items x 10)
(E4 D4 E4 D4 E4 G4 E4 E4 F4 E4)

See Also:

*cm-state*, Item Streams, *random-range*


Last Modified: 5-Mar-1998