By default all the case statements have got the same extraction probability.
You can alter the probability specifying an integer weight parameter greater than 1.
Where 1 is the default (implicit) weight for each case statement.
fortune {
case [<weight1>]: {
<statement block 1>
}
case [<weight2>]: {
<statement block 2>
}
.....
case [<weightN>]: {
<statement block N>
}
}
<statement block 1>
}
case [<weight2>]: {
<statement block 2>
}
.....
case [<weightN>]: {
<statement block N>
}
}
Example:
fortune {
case 3: { # 75% of probability
output 'Good Morning!';
}
case 1: { # 25% of probability
output 'Good Night!';
}
}
Let me give credit to Massimiliano "TheDaemon" Cuzzoli for this language construction.
No comments:
Post a Comment