Probabilistic choice: Difference between revisions

→‎{{header|Perl 6}}: added .race for concurrency, now requires atomic ops
m (→‎{{header|Ring}}: Remove vanity tags)
(→‎{{header|Perl 6}}: added .race for concurrency, now requires atomic ops)
Line 2,156:
 
=={{header|Perl 6}}==
{{works with|rakudoRakudo|2015-2018.10-20}}
<lang perl6>constant TRIALS = 1e6;
Line 2,164:
constant @cP = [\+] @P;
my atomicint @results[+@event];
(^TRIALS).race.map: { @results[ @cP.first: { $_ > once rand }, :k ]++; xx TRIALS;}
 
say 'Event Occurred Expected Difference';
for ^@results {
2,392

edits