simply scheme 第三章 练习
2010-07-03 18:43
197 查看
3.1 Translate the arithmetic expressions (3+4)×5 and 3+(4×5) into Scheme expressions, and into plumbing diagrams.
(× (+ 3 4) 5) (+ 3 (× 4 5))
3.2 How many little people does Alonzo hire in evaluating each of the following expressions:
(+ 3 (* 4 5) (- 10 4)) (* (- (/ 8 2) 1) 5) 2) 6个
(* (+ (- 3 (/ 4 2)) (sin (* 3 2))(- 8 (sqrt 5))) (- (/ 2 3) 4)) 10个
3.3 Each of the expressions in the previous exercise is compound. How many subex- pressions (not including subexpressions of subexpressions) does each one have?
For example,
(* (- 1 (+ 3 4)) 8) has three subexpressions; you wouldn’t count (+ 3 4).
3.4 Five little people are hired in evaluating the following expression:
(+ (* 3 (- 4 7))(- 8 (- 3 5)))
Give each little person a name and list her specialty, the argument values she receives, her return value, and the name of the little person to whom she tells her result.
(+ (* 3 -3) (- 8 -2))=(+ -9 10)=1
3.5 Evaluate each of the following expressions using the result replacement technique:
(sqrt (+ 6 (* 5 2)))=4
(+ (+ (+ 1 2) 3) 4)=10
3.6 Draw a plumbing diagram for each of the following expressions:
(+ 3 4 5 6 7) (+ (+ 3 4) (+ 5 6 7)) (+ (+ 3 (+ 4 5) 6) 7)
自己画
3.7 What value is returned by (/ 1 3) in your version of Scheme? (Some Schemes return a decimal fraction like 0.33333, while others have exact fractional values like 1/3 built in.)
1/3
3.8 Which of the functions that you explored in Chapter 2 will accept variable numbers of arguments?
+ * operations
3.9 The expression (+ 8 2) has the value 10. It is a compound expression made up of three atoms. For this problem, write five other Scheme expressions whose values are also the number ten:
• An atom 10
• Another compound expression made up of three atoms (+ 1 9)
• A compound expression made up of four atoms (+ 1 3 6)
• A compound expression made up of an atom and two compound subexpressions (+ 1 (+ 1 2) (+ 1 5))
• Any other kind of expression ...
相关文章推荐
- C++Primer Plus 第三章编程练习个人答案
- C primer plus(第五版)编程练习第三章
- 关于于渊的一个操作系统的实现第二版学习之第三章bochs裸机启动的练习3.1
- 《Python核心编程》第三章练习解析
- 第三章练习6,输出1+2+3+4+n小于8888的最大整数N
- java 编程思想 第三章 练习14
- 第三章 3.3.1节练习 & 3.3.2节练习
- 第三章 3.5.5节练习
- 《Python核心编程》 第三章 Python基础 - 练习
- 第三章 表单(课堂练习)
- 《Thinking in c++》第二册 ————第三章 练习一
- Functional Programming in Scala第三章练习
- 整理模拟练习8 第三章 会计电算化的工作环境
- C primer plus 第三章编程练习(个人练习答案)
- SQL 第三章 练习
- 第三章上机练习
- C和指针第三章--编程练习
- 《c primer plus》编程练习回顾-第三章
- C++ Primer Plus第五版 第三章 编程练习答案
- 第一本书 第三章上机练习1-3