Exercise 1.9
terms of the procedures inc, which increments its argument by 1, and dec, which decrements its
argument by 1
(define (+ a b)(if (= a 0)b(inc (+ (dec a) b)))) (define (+ a b)(if (= a 0)b(+ (dec a) (inc b))))
Are these processes iterative or recursive?
这两个函数,分别使用两个用于自增(inc)和自减(dec)变量的方法组成,使用substitution model来展开它们计算(+ 4 5)的过程,并且指出他们的过程是迭代还是递归。
严格的按照过程展开即可
第一个:
(+ 4 5) (inc (+ (dec 4) 5)) (inc (+ 3 5)) (inc (inc (+ (dec 3) 5))) (inc (inc (+ 2 5))) (inc (inc (inc (+ 1 5)))) (inc (inc (inc (inc (+ 0 5))))) (inc (inc (inc (inc 5)))) (inc (inc (inc 6))) (inc (inc 7)) (inc 8) 9
这个是一个递归过程
第二个方法:
(define (+ a b)(if (= a 0)b(+ (dec a) (inc b)))) (+ 4 5) (+ 3 6) (+ 2 7) (+ 1 8) (+ 0 9) 9
这个显然是迭代。
Exercise 1.9相关推荐
- 区别 eks_sport 和 exercise 有什么区别?看完你就清楚了!
说到"运动"sport 这个单词应该是不少人看到"运动"的第一反应吧 sport /spɔ:t/ n.体育运动 例如:I'd say football is m ...
- 【DeepLearning】Exercise:Sparse Autoencoder
Exercise:Sparse Autoencoder 习题的链接:Exercise:Sparse Autoencoder 注意点: 1.训练样本像素值需要归一化. 因为输出层的激活函数是logist ...
- (14)Why some people find exercise harder than others
https://www.ted.com/talks/emily_balcetis_why_some_people_find_exercise_harder_than_others/transcript ...
- MIT 6.828 JOS学习笔记12 Exercise 1.9
Lab 1中Exercise 9的解答报告 Exercise 1.9: 判断一下操作系统内核是从哪条指令开始初始化它的堆栈空间的,以及这个堆栈坐落在内存的哪个地方?内核是如何给它的堆栈保留一块内存空间 ...
- Exercise: Logistic Regression and Newton's Method
Exercise: Logistic Regression and Newton's Method 题目地址: Exercise: Logistic Regression 题目概要:某个高中有8 ...
- Exercise: Linear Regression
Exercise: Linear Regression 题目地址: http://openclassroom.stanford.edu/MainFolder/DocumentPage.php?c ...
- RDC Lent ifm IP Analysis Exercise
RDC Lent ifm IP Analysis Exercise 文章目录 RDC Lent ifm IP Analysis Exercise Team Intro Introduction to ...
- Basketball Exercise CodeForces - 1195C(动态规划dp)
Finally, a basketball court has been opened in SIS, so Demid has decided to hold a basketball exerci ...
- UFLDL教程:Exercise:Convolution and Pooling
Deep Learning and Unsupervised Feature Learning Tutorial Solutions CNN的基本结构包括两层 其一为特征提取层,每个神经元的输入与前一 ...
- UFLDL教程: Exercise:Learning color features with Sparse Autoencoders
Linear Decoders Deep Learning and Unsupervised Feature Learning Tutorial Solutions 以三层的稀疏编码神经网络而言,在s ...
最新文章
- Java项目:宠物商城系统(java+Springboot+Maven+mybatis+Vue+mysql)
- 场景解析--Pyramid Scene Parsing Network
- django-2 模板文件的加载
- SVN代码冲突解决方案小集合
- javascript 垃圾回收机制--分代式垃圾回收机制
- LintCode刷题——不同的二叉查找树I、II
- openssl生成https证书 (转)
- php判断除数是不是整数,五种js判断是否为整数类型方式
- linux 宽字符串,C语言中的多字节字符与宽字符
- web前端学习之HTML
- ofo败局中唯一赚到钱的只有他?当事人回应......
- Python3.x伪随机,元素重排,矩阵
- 华为悬红“奥林帕斯奖”,促进数据产业基础技术研究与生态建设
- 关于SQL的重复记录问题
- 飞思卡尔单片机c语言编程详解,主流16位单片机学习详解:飞思卡尔MC9S12G系列...
- 树莓派 串口如何使用 以及树莓派引脚对照表
- 【重要】股票收益互换
- KODI(原XBMC)二次开发完全解析(一)
- python微信群管理开禁言_微信群主怎么禁言别人?微信群怎么让群员禁言?
- 京东首页案例(流式布局)