Seven-sided dice from five-sided dice: Difference between revisions

Content added Content deleted
Line 1,245: Line 1,245:
end</lang>
end</lang>
=={{header|M2000 Interpreter}}==
=={{header|M2000 Interpreter}}==
We make a stack object (is reference type) and pass it as a closure to dice7 lambda function.
We make a stack object (is reference type) and pass it as a closure to dice7 lambda function. For each dice7 we pop the top value of stack, and we add a fresh dice5 (random(1,5)) as last value of stack, so stack used as FIFO. Each time z has the sum of 7 random values.
For each dice7 we pop the top value of stack, and we add a fresh dice5 (random(1,5)) as last value of stack, so stack used as FIFO.
Each time z has the sum of 7 random values.


We check for uniform numbers using +-5% from expected value.
We check for uniform numbers using +-5% from expected value.
<lang M2000 Interpreter>
<lang M2000 Interpreter>


Module CheckIt {
Module CheckIt {
Def long i, calls, max, min
Def long i, calls, max, min
Line 1,303: Line 1,299:




1 100081
1 100214
2 99519
2 100336
3 99897
3 100049
4 99823
4 99505
5 100649
5 99951
6 100265
6 99729
7 99766
7 100216
min=99519 expected=100000 max=100649
min=99505 expected=100000 max=100336
Verify Uniform:uniform
Verify Uniform:uniform
</pre >
</pre >