Monty Hall problem: Difference between revisions

Emacs Lisp: Improve formatting
m (→‎{{header|Phix}}: added syntax colouring, marked p2js compatible)
(Emacs Lisp: Improve formatting)
Line 1,669:
=={{header|Emacs Lisp}}==
{{trans|Picolisp}}
<lang lisp>(defun montyhall (keep)
(let ((prize (random 3))
(defun montyhall (keep)
(choice (random 3)))
(let
((prize (random 3))
(choice (random 3)))
(if keep (= prize choice)
(/= prize choice))))
 
 
(let ((cnt 0))
(dotimes (i 10000)
(and (montyhall t) (setq cnt (1+ cnt))))
(princ (formatmessage "Strategy keep: %.3f %%" (/ cnt 100.0))))
 
(let ((cnt 0))
(dotimes (i 10000)
(and (montyhall nil) (setq cnt (1+ cnt))))
(princ (formatmessage "Strategy switch: %.3f %%" (/ cnt 100.0))))</lang>
</lang>
 
{{out}}
 
<pre>
Strategy keep: 34.410 %
Strategy switch: 66.430 %
</pre>
 
=={{header|Erlang}}==
Anonymous user