Exercise 1.5.  Ben Bitdiddle has invented a test to determine whether the interpreterhe is faced with is using applicative-order evaluation or normal-orderevaluation. He defines the following two procedures:

(define (p) (p))



(define (test x y)

  (if (= x 0)

      0

      y))

Then he evaluates the expression

(test 0 (p))

What behavior will Ben observe with an interpreter that usesapplicative-order evaluation? What behavior will he observe with aninterpreter that uses normal-order evaluation?

Explain your answer.(Assume that the evaluation rule for the special form
if
is the same whether the interpreter is using normal or applicative order:The predicate expression is evaluated first, and the result determines whether to evaluatethe consequent or the alternative expression.)

1、无參数函数

(define (p) (+ 1 2) )

;Value p

p

;Value 18:#[compound-procedure 18 p]

(p)

;Value 3

比較一下:

(define x (+ 1 2) )

;Value x

x

;Value 3

2、无限循环

(define (p) (p))无限循环。前一个(p)定义无參数函数,后一个(p)表示调用自己。

3.应用序和正则序的差别

应用序:(test 0 (p))时,先求值(p)——无限循环,再将(p)的值带入

(if (= x 0)

      0

      y))

正则序:(test 0 (p))时。先带入/展开,即

(if (= x 0)

      0

      (p)))

依照if求值顺序,推断0=0,结果为#t。

注意:if为正则序

最新文章

  1. UI篇(初识君面)
  2. 《HelloGitHub月刊》第08期
  3. Activiti工作流学习(三)Activiti工作流与spring集成
  4. Material Design Lite,简洁惊艳的前端工具箱 之 交互组件。
  5. 扩展html 无边框的input 边框
  6. 我体验过的可以用的XCode插件
  7. BZOJ3570 : DZY Loves Physics I
  8. Mysql 正则获取字段的交集【转】
  9. ubuntu14.04安装opencv3.0
  10. mac 下svn降级
  11. python自动开发之第十三天
  12. 一个好用的Python备份mysql的脚本
  13. css-下拉菜单案例
  14. EasyUI - DataGrid 组建 - [ 排序功能 ]
  15. poj-3791-An Easy Game-记忆化搜索
  16. C#触发器知识总结及案例
  17. Matplotlib学习---matplotlib的一些基本用法
  18. Memcached入门学习
  19. Git和Github入门教程
  20. 牛客网测试题--小a和黄金街道

热门文章

  1. Windows 之 防火墙
  2. Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-6.xml, reason: Connection to https://dl-ssl.google.com refused
  3. Gradle修改Maven仓库地址
  4. alias的使用
  5. Linux rpm 命令参数使用详解[介绍和应用]
  6. Spring Web MVC 原理学习(下)
  7. Eclipse的tomcat插件
  8. virtual的使用方法
  9. Codeforces554C:Kyoya and Colored Balls(组合数学+费马小定理)
  10. (二)Linux实操之——网络配置、进程管理、服务管理、组管理、YUM