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

sicp每日一题[2.7]

2.7

Alyssa’s program is incomplete because she has not specified the implementation of the interval abstraction. Here is a definition of the interval constructor:
(define (make-interval a b) (cons a b))
Define selector s u p p e r − b o u n d supper-bound supperbound and l o w e r − b o u n d lower-bound lowerbound to complete the implementation.


这道题目难度不大,比起前面的选择函数,就是多了一个取最小值为下界,最大值为上界的步骤,直接利用现成的 m i n , m a x min, max min,max 即可。

; x 表示某个区间
(define (lower-bound x) (min (car x) (cdr x)))(define (upper-bound x) (max (car x) (cdr x)))(define helper (make-interval 1.0 1.0))
(define r1 (make-interval 6.12 7.48))
(define r2 (make-interval 4.465 4.935)); 计算并联电路的电阻,注意这里不能化简成 r1*r2/(r1+r2) 的形式
(define (parallel-resistance r1 r2)(div-interval helper (add-interval (div-interval helper r1)(div-interval helper r2))))(display (parallel-resistance r1 r2)); 执行结果
[2.581558809636278, 2.97332259363673]

http://www.mrgr.cn/news/25918.html

相关文章:

  • 高颜值浅色系可视化界面,用在B端,无出其右。
  • (不用互三)AI绘画工具大比拼:Midjourney VS Stable Diffusion该如何选择?
  • Verilog和Matlab实现RGB888互转YUV444
  • 【ESP-IDF FreeRTOS】事件组
  • 基于Web的门店管理系统的设计与实现---附源码76269
  • Jetpack Compose Side Effects in Details 副作用的详细信息
  • 通过 Sniper Links 提高您的电子邮件确认率
  • 【SSRF漏洞】——http协议常见绕过
  • K1计划100%收购 MariaDB; TDSQL成为腾讯云核心战略产品; Oracle@AWS/Google/Azure发布
  • java 可变参数
  • java.io.IOException: Too many open files 分析与解决
  • [DCVRP] 基于复杂网络的k-opt算法解空间表示(五)
  • ElementPlus自定义更换主题色
  • Excel图片批量插入单元格排版处理插件【图片大师】
  • 出海公司如何快速搭建海外团队指南
  • MongoDB与Pymongo深度实践:从基础概念到无限级评论应用示例
  • 项目实战应用Redis分布式锁
  • 828华为云征文|华为云Flexus云服务器X实例之openEuler系统下部署CodeX Docs文档工具
  • python 实现euler modified变形欧拉法算法
  • 学懂C++(六十):C++ 11、C++ 14、C++ 17、C++ 20新特性大总结(万字详解大全)