fork download
  1. (defun correct (a b)
  2. (if (= a b) nil a))
  3.  
  4. (defun make-unbiased-coin (biased-coin)
  5. (lambda ()
  6. (loop for a = (funcall biased-coin) then (funcall biased-coin)
  7. and b = (funcall biased-coin) then (funcall biased-coin)
  8. while (null (correct a b))
  9. finally (return (correct a b)))))
  10.  
  11. (let* ((bc (lambda () (if (< 7 (random 10)) 0 1)))
  12. (uc (make-unbiased-coin bc)))
  13. (pprint (loop repeat 10 collecting
  14. (loop repeat 1000 summing (funcall uc)))))
Success #stdin #stdout 0.14s 10728KB
stdin
Standard input is empty
stdout
(469 489 489 493 508 484 514 492 477 494)