Skip to content

Instantly share code, notes, and snippets.

@yao2030
Created December 7, 2012 03:10
Show Gist options
  • Save yao2030/4230451 to your computer and use it in GitHub Desktop.
Save yao2030/4230451 to your computer and use it in GitHub Desktop.
;; Exercise 1.39
;; sicp
(define (tan-cf x k)
(define (n i)
(if (= i 1)
x
(square x)))
(define (d i)
(- (* 2 i) 1))
(define (cont-frac n d k)
(define (cont-help counter result)
(if (= counter 0)
result
(cont-help (- counter 1) (/ (n counter) (- (d counter) result)))))
(cont-help k 0.0))
(cont-frac n d k))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment