4.3.2. Examples of Nondeterministic Programs
Exercise 4.47

Alternative variant of parse-verb-phrase

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?


Nobody's finished this exercise yet. You'll be the first!


There are no comments yet.

Authentication required

You must log in to post a comment.

Login