Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. (define (iterate start-value next-value start-index next-index finished?)
  2. (define (inner-iter cur-val cur-index)
  3. (if (finished? cur-val cur-index)
  4. cur-val
  5. (inner-iter (next-value cur-val cur-index) (next-index cur-val cur-index))))
  6. (inner-iter start-value start-index))
  7.  
  8. ; b)
  9. (define (phi n)
  10. (if (= n 0)
  11. 1.0
  12. (iterate
  13. 1.0 (lambda (cur-val cur-index) (+ 1 (/ 1 cur-val))) ; Start-Wert und Werteberechnung (1+1/vorherigen wert)
  14. 0 (lambda (cur-val cur-index) (+ cur-index 1)) ; Start-Index und Indexerhöhung (index++)
  15. (lambda (cur-val cur-index) (if (= n cur-index) #t #f)) ; Endabfrage (index == n)
  16. )))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement