Chinaunix首页 | 论坛 | 博客
  • 博客访问: 16029
  • 博文数量: 8
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 80
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-12 09:58
文章分类
文章存档

2013年(8)

我的朋友

分类: IT业界

2013-09-12 10:02:49


点击(此处)折叠或打开

  1. ;; The first three lines of this file were inserted by DrRacket. They record metadata
  2. ;; about the language level of this file in a form that our tools can easily process.
  3. #reader(lib "htdp-advanced-reader.ss" "lang")((modname e18) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ())))
  4. (define (div-three x)
  5. (/ x 3.0))
  6. ;;(div-three 1 3)
  7. (define (three-times x)
  8. (* x x x))
  9. ;;(three-times 2)
  10. (define (square x)
  11. (* x x)
  12. )
  13. ;;(square 2)
  14. (define (make-nums guess x)
  15. (+ (+ guess guess) (/ x (square guess))))
  16. ;;(make-nums 2 8)
  17. (define (improve guess x)
  18. (div-three (make-nums guess x))
  19. )
  20. ;;(improve 2 8)
  21. (define (good-enough? guess x)
  22. (< (abs (- (three-times guess) x)) 0.001))
  23. ;;(good-enough? 2 8)
  24. (define (three-sqrt-iter guess x )
  25. (if (good-enough? guess x)
  26. guess
  27. (three-sqrt-iter (improve guess x) x)))
  28. ;;(three-sqrt-iter 2 8)
  29. (define (three-sqrt x)
  30. (three-sqrt-iter 1.0 x))
  31. (three-sqrt 27)


阅读(186) | 评论(0) | 转发(0) |
0

上一篇:没有了

下一篇:When a Jaw Crusher Is sick,the Three Possibilities

给主人留下些什么吧!~~