Question: That is a pi calculating program in scheme. Is there a way to get rid of if and put cond there? (define (pi err) (let
That is a pi calculating program in scheme. Is there a way to get rid of "if" and put "cond" there?
(define (pi err) (let loop ([n 0] [prev +nan.0] [cur 0.0]) (cond ((< (abs (- cur prev)) (/ err4.0)) (* 4.0 prev)) (else(loop (add1 n) cur ((if (even? n) + -) cur (/ 1.0 (+ 1.0 n n))))))))
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
