Vocabularycombinators.randomInputsassoc | a sequence of probability/word pairs with an optional quotation at the end |
OutputsNone
Word descriptionCalls the different quotations randomly with the given probability. Unlike
casep, the probabilities are interpreted as conditional probabilities. All probabilities must be numbers between 0 and 1. The sequence must end with a pair whose probability is one, or a quotation. These rules are enforced during the macro expansion by throwing
bad-probabilities if they are not respected.
ExamplesThe following two forms will output 1 with 0.5 probability, 2 with 0.25 probability and 3 with 0.25 probability
USING: combinators.random prettyprint ;
{
{ 0.5 [ 1 ] }
{ 0.5 [ 2 ] }
{ 1 [ 3 ] }
} casep* .
USING: combinators.random prettyprint ;
{
{ 0.5 [ 1 ] }
{ 0.5 [ 2 ] }
[ 3 ]
} casep* .
See alsocasepDefinition