Chapter 1, Building Abstractions with Procedures
Section - Formulating Abstractions with Higher-Order Procedures
Exercise 1.39
Procedure:
1
2
3
4
5
6
7
(define (tan-cf x n)
(let ((num-const (* -1 x x)))
(define (num k) (if (= k 1) x num-const))
(define (den k) (- (* 2 k) 1))
(cont-frac-itr num den n)
)
)
Sample output:
1
2
3
4
5
6
7
(define pi (/ 22.0 7))
> (tan-cf (/ pi 4) 10)
; 1.0006324445845896
> (tan-cf 0 10)
; 0