Last active
April 13, 2022 01:39
-
-
Save cataska/4c8437287048256d97eed95881f017ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(setf *random-state* (make-random-state t)) | |
(defun dice () | |
(random 2)) | |
(defun roll (n) | |
(let ((x 0) | |
(count 0)) | |
(loop while (< x n) do | |
(incf count) | |
(if (= 1 (dice)) | |
(incf x) | |
(setq x 0))) | |
count)) | |
(defvar times 10) | |
(loop for i from 1 to times do | |
(format t "#~A 第 ~A 次:擲出 ~A 次正面~%" i (roll times) times)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment