Skip to content

Commit

Permalink
remove 'wrong' parameter from monty-hall-iter
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilliamson1 committed Sep 6, 2017
1 parent 8c2dd9a commit cf58048
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
16 changes: 15 additions & 1 deletion 2.6 church numerals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,18 @@
(lambda (f)(lambda (x) (f (((lambda (fn) (lambda (x) x)) f) x)))))

(define (add-1 (lambda (fn) (lambda (x) x))) ;returns
(lambda (f)(lambda (x) (f ((lambda (f) (lambda (x) x)) x)))))
(lambda (f)(lambda (x) (f ((lambda (f) (lambda (x) x)) x)))))
----
(define (add-1 n) ;returns
(lambda (f)(lambda (x) (f ((n f) x)))))

(define one (lambda (fn) (lambda (x) (fn x))))

(define (add-1 (lambda (fn) (lambda (x) (fn x)))) ;returns
(lambda (f)(lambda(x)(f ((lambda (fn) (lambda (x) (fn x))) f) x)))))

(define (add-1 (lambda (fn) (lambda (x) (fn x)))) ;returns
(lambda (f)(lambda(x)(f ((lambda (x) (f x)) x)))))

(define (add-1 (lambda (fn) (lambda (x) (fn x)))) ;returns
(lambda (f)(lambda(x)(f (f x))))
14 changes: 7 additions & 7 deletions montyhall.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
(else(cons (car list)(remove-door n (cdr list))))))


;(pick 1 '(alpha delta doggmega))
;(pick 2 '(alpha delta doggmega))
;(pick 3 '(alpha delta doggmega))
;(pick 1 '(alpha delta dog))
;(pick 2 '(alpha delta dog))
;(pick 3 '(alpha delta dog))

(define (a-trial)

Expand Down Expand Up @@ -66,12 +66,12 @@

(define (monty-hall n)
(define total-trials n)
(define (monty-hall-iter n right wrong)
(define (monty-hall-iter n right)
(cond
((= n 0)(newline)(newline)(display "ratio correct: ")(display (/ right total-trials)))
((a-trial)(newline)(display "correct")(monty-hall-iter (- n 1) (+ 1 right) wrong))
(else (newline)(display "incorrect")(monty-hall-iter (- n 1) right (+ 1 wrong)))))
(monty-hall-iter n 0 0))
((a-trial)(newline)(display "correct")(monty-hall-iter (- n 1) (+ 1 right)))
(else (newline)(display "incorrect")(monty-hall-iter (- n 1) right))))
(monty-hall-iter n 0))

;run simulation 1000 times
(monty-hall 1000)
Expand Down

0 comments on commit cf58048

Please sign in to comment.