cont−frac是递归
cont−frac−linear是迭代
(define (cont-frac n d k)
(define (iter i)
(if (= i k)
(/ (n i) (d i))
(/ (n i) (+ (d i) (iter (+ i 1))))))
(iter 1))
(newline)
(display (cont-frac (lambda (i) 1.0)
(lambda (i) 1.0)
100))
(define (cont-frac-linear n d k)
(define (iter i result)
(if (= i 0)
result
(iter (- i 1) (/ (n i) (+ (d i) result)))))
(iter k 0))
(newline)
(display (cont-frac-linear (lambda (i) 1.0)
(lambda (i) 1.0)
100))