Probabilistic choice: Difference between revisions
→{{header|Perl 6}}: added .race for concurrency, now requires atomic ops
Thundergnat (talk | contribs) m (→{{header|Ring}}: Remove vanity tags) |
SqrtNegInf (talk | contribs) (→{{header|Perl 6}}: added .race for concurrency, now requires atomic ops) |
||
Line 2,156:
=={{header|Perl 6}}==
{{works with|
<lang perl6>constant TRIALS = 1e6;
Line 2,164:
constant @cP = [\+] @P;
my atomicint @results[+@event];
(^TRIALS).race.map: { @results[ @cP.first: { $_ > once rand }, :k ]⚛++;
say 'Event Occurred Expected Difference';
for ^@results {
|