9
10
2012
11

正则序和应用序

练习1.5

Ben 发明了一种检测方法来确定Lisp的解释器采用应用序(Applicative Order)还是正则序(Normal Order)来求值。

他定义了下面两个过程并进行检测:

;过程定义
(define (p) (p))
(define (test x y)
        (if (= x 0) 0 y))
;检测
(test 0 (p))

问解释器使用应用序和正则序时分别输出什么结果?


解释器怎么解释这段程序呢?

如果是按正则序的话,解释器会“完全展开而后规约”,所以求值流程如下:

(test 0 (p))
;展开test 得到以下程序
(if (= 0 (p)) 0 (p))
;对谓词(= )进行求值
(if (#t) 0 (p))
;谓词等于真 返回0
0

这个if语句的行为很重要,实际上if发现(p)并没有被求值的必要。

如果是按应用序的话,解释器会“先对参数求值而后应用”,所以流程如下:

(test 0 (p))
;对参数(p)求值,根据(p)的定义,解释器又得到了(p)
(test 0 (p))
;程序将不会产生有意义的输出
Category: SICP | Tags: SICP 正则序 应用序 Applicative Order Normal Order | Read Count: 2346
cleaning services ua 说:
2019年9月12日 09:24

This can be the same intended for private households. Many persons love which has a cleaning service also come in to fresh those parts entrance that the majority of people hate to decontaminate. Perhaps they're going to contract that has a company to help just complete floors, microsoft windows, toilets in addition to bathtubs along with the rest the proprietor will complete. Or they will have someone who'd want the full home cleaned a couple of times a full week. Having some sort of cleaning corporation who present you with a large a number of services can certainly surely you need to everyone.

www.cleantechlaws.co 说:
2020年6月04日 13:30

There may be more which will get what you long for than simply just knowing around the Law connected with Attraction. Ever due to the fact "The Secret" turned out the earth has modified - this movie awakened the little brown eyes and heart of people in the world. What an excellent benefit.

www.bankruptcylawmer 说:
2020年6月04日 13:31

This spiritual Rules of Pay out, as displayed by William Proctor from the 11 Ignored Laws, is concerning increasing your capacity in each and every way; our capacity to obtain, to catch the attention of, and to help praise, one example is. The first thing we should understand is which the Law connected with Compensation is usually a spiritual rules.

www.duilawyermontrea 说:
2020年6月04日 13:31

Students that are looking for to come to be attorneys ought to successfully complete the precise amount connected with schooling. Students should complete a selected level connected with education as a way to practice rules. Online universites and colleges offer learners numerous prospects to move into employment opportunities.

www.wendywoodlaw.com 说:
2020年6月04日 13:32

The final practice connected with family law will likely be examined in this particular concentration. Students be able to handle custody disputes, divorce, abuse conditions, and far more. Education commonly includes normal criminal rules and each of the necessary spouse and children law lessons. Adoption rules, legal proper rights of little ones, and nontraditional spouse and children law usually are some lessons taken.

www.starliteshopping 说:
2020年6月04日 13:32

The technique of a nonprofit shop ranges from state to state. For case, it is referred to as thrift retail store, resale retail outlet, hospice shop in the states and The us, Opportunity (op) retail outlet in Quotes and Completely new Zealand in addition to 2nd give shop with Malaysia.

maids in dubai 说:
2020年6月11日 10:37

Starting the process to take part the services of any maid is normally trying plenty of, but that is certainly only the beginning. Following your responsibility to seek the services of a house maid, you then ought to be very very careful about selecting the right service service.

painters in Dubai 说:
2020年6月11日 10:38

Contemplate Ungaretti & Harris, a lawyers in Chi town that picked up bragging rights and many good ink when the item became the primary law firm near you to think of a published service assurance. The corporation pledges cost-effective in addition to timely services and beneficial communication while using the client.

attitude status for 说:
2021年4月21日 13:45

Download the attitude status for the girls here on this website.

live in maids dubai 说:
2021年6月13日 07:39

We're a extremely reputed cleansing company delivering the best cleaning as well as professional renovator services. We are merely among the best local cleansing companies within Dubai. Not just do we focus on residential customers, we further concentrate on corporate customers too.

seo service UK 说:
2024年1月16日 10:04

 little garage door troubleshooting can go a long way in maintaining your door’s build and functionality. Because of the quantity of cycles your garage door endures through daily use, garage door repairs and annual maintenance are commo


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com