fork download
  1.  
  2.  
  3. (define (cont-frac n d k)
  4. (define (frac i)
  5. (if (< i k)
  6. (/ (n i)
  7. (+ (d i) (frac (+ i 1))))
  8. (/ (n i) (d i))))
  9. (frac 1))
  10.  
  11.  
  12. (define (cont-frac-iter numenator denominator k)
  13. (define (iter i result)
  14. (if (= i 0)
  15. result
  16. (iter (- i 1)
  17. (/ (numerator i)
  18. (+ (denominator i)
  19. result)))))
  20. (frac-iter (- k 1)
  21. (/ (numerator k)
  22. (denominator k))))
  23.  
  24. (display (cont-frac (lambda (i) 1.0)
  25. (lambda (i) 1.0)
  26. 100))
  27. (newline)
  28.  
  29. (display (cont-frac-iter (lambda (i) 1.0)
  30. (lambda (i) 1.0)
  31. 100))
  32. (newline)
  33.  
Runtime error #stdin #stdout #stderr 0.07s 10472KB
stdin
Standard input is empty
stdout
0.6180339887498948
stderr
Backtrace:
In ice-9/boot-9.scm:
 157: 12 [catch #t #<catch-closure 88d1bd0> ...]
In unknown file:
   ?: 11 [apply-smob/1 #<catch-closure 88d1bd0>]
In ice-9/boot-9.scm:
  63: 10 [call-with-prompt prompt0 ...]
In ice-9/eval.scm:
 432: 9 [eval # #]
In ice-9/boot-9.scm:
2401: 8 [save-module-excursion #<procedure 88e0cc0 at ice-9/boot-9.scm:4045:3 ()>]
4052: 7 [#<procedure 88e0cc0 at ice-9/boot-9.scm:4045:3 ()>]
1724: 6 [%start-stack load-stack ...]
1729: 5 [#<procedure 88e6738 ()>]
In unknown file:
   ?: 4 [primitive-load "/home/FfyND2/prog.scm"]
In ice-9/eval.scm:
 387: 3 [eval # ()]
 386: 2 [eval # #]
 393: 1 [eval # #]
In unknown file:
   ?: 0 [memoize-variable-access! #<memoized frac-iter> #<directory # 885d630>]

ERROR: In procedure memoize-variable-access!:
ERROR: Unbound variable: frac-iter