当前位置: 首页 > article >正文

sicp每日一题[2.12]

Exercise 2.12

Defineaconstructor m a k e − c e n t e r − p e r c e n t make-center-percent makecenterpercent that takes a center and a percentage tolerance and produces the desired interval. You must also define a selector p e r c e n t percent percent that produces the percentage tolerance for a given interval. The c e n t e r center center selector is the same as the one shown above.


我以为这是上道题的要求,已经实现了。。

; 把 w 改为百分比形式
(define (make-center-width c w)
  (let ((tolerance (* c w)))
    (make-interval (- c tolerance) (+ c tolerance))))

(define (center i)
  (average (lower-bound i) (upper-bound i)))

(define (percent i)
  (* (/ (/ (- (upper-bound i) (lower-bound i)) 2)
        (center i))
     100))

(define (display-interval-tolerance i) 
  (newline)
  (display (center i))
  (display " ± ")
  (display (percent i))
  (display "%"))

(define a (make-interval 6.12 7.48))
(define b (make-interval 4.465 4.935))


(display-interval-tolerance a)
(display-interval-tolerance b)

; 执行结果
6.800000000000001 ± 10.000000000000002%
4.699999999999999 ± 4.999999999999998%

http://www.kler.cn/news/307793.html

相关文章:

  • 进阶SpringBoot之 Swagger 分组与接口注释
  • 中级练习[10]:Hive SQL
  • MySQL数据的增删改查(一)
  • 认识原码反码补码
  • 一文快速上手-create-vue脚手架
  • 2024年CAD图纸加密软件|加密图纸软件推荐:10款高效CAD加密软件
  • 苍穹外卖Day01
  • 技嘉RTX 4070 SUPER WUKONG OC显卡评测:天命人最佳2K游戏搭档 温度仅61℃
  • UE5-俯视角色移动(蓝图)01
  • 解密AI创作:提升Prompt提示词的提问技巧
  • 学习之git的远程仓库操作的常用命令
  • C++3D迷宫
  • GO 反射
  • CNSS Recruit 2024 Web方向 题解WriteUp
  • git编译安装报错
  • 基于STM32的温度、电流、电压检测proteus仿真系统(OLED、DHT11、继电器、电机)
  • 计算机毕业设计 高校学术交流平台的设计与实现 Java实战项目 附源码+文档+视频讲解
  • 借助大模型将文档转换为视频
  • html+css+js网页设计 旅游 厦门旅游网10个页面
  • element-plus的面包屑组件el-breadcrumb
  • 使用 SuperCraft AI 设计书橱模型的指南
  • 简单代码实现视频转图片_py
  • 在Flask中实现日志记录
  • 动态ip切换频率是快点好还是慢点好
  • Mybatis批量操作
  • Java 使用 Redis
  • 并发容器(Map、List、Set)实战及其原理分析
  • 如何快速清理Docker中的停止容器?
  • HFish开源蜜罐系统常见问题排查
  • 10- 【JavaWeb】Tomcat、Servlet基础