Exercise 4.47: Louis Reasoner suggests that,
since a verb phrase is either a verb or a verb phrase followed by a
prepositional phrase, it would be much more straightforward to define the
procedure parse-verb-phrase as follows (and similarly for noun phrases):
(define (parse-verb-phrase)
(amb (parse-word verbs)
(list
'verb-phrase
(parse-verb-phrase)
(parse-prepositional-phrase))))
Does this work? Does the program’s behavior change if we interchange the order
of expressions in the amb?
练习 4.47:Louis Reasoner 认为,由于动词短语要么是一个动词,要么是一个动词短语后跟一个介词短语,因此将过程 parse-verb-phrase 定义为以下形式(名词短语的处理类似)会更加直接:
(define (parse-verb-phrase)
(amb (parse-word verbs)
(list
'verb-phrase
(parse-verb-phrase)
(parse-prepositional-phrase))))
这样可行吗?如果我们交换 amb 中表达式的顺序,程序的行为会改变吗?
(define (parse-verb-phrase)
(amb (parse-word verbs)
(list
'verb-phrase
(parse-verb-phrase)
(parse-prepositional-phrase))))