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

CL D7 from D5
(→‎{{header|OCaml}}: use hash table)
(CL D7 from D5)
Line 39:
return 0;
}</lang>
 
=={{header|Common Lisp}}==
{{trans|C}}
<lang lisp>(defun d5 ()
(1+ (random 5)))
 
(defun d7 ()
(do ((d55 #1=(+ (* 5 (d5)) (d5) -6) #1#))
((< d55 21) (1+ (mod d55 7)))))</lang>
 
<pre>> (check-distribution 'd7 1000)
Distribution potentially skewed for 1: expected around 1000/7 got 153.
Distribution potentially skewed for 2: expected around 1000/7 got 119.
Distribution potentially skewed for 3: expected around 1000/7 got 125.
Distribution potentially skewed for 7: expected around 1000/7 got 156.
T
#<EQL Hash Table{7} 200B5A53>
 
> (check-distribution 'd7 10000)
NIL
#<EQL Hash Table{7} 200CB5BB></pre>
 
=={{header|OCaml}}==
Anonymous user