Exercise 4.49. Alyssa P. Hacker is more interested in generating interesting sentences than in parsing them. She reasons that by simply changing the procedure parse-word so that it ignores the ``input sentence'' and instead always succeeds and generates an appropriate word, we can use the programs we had built for parsing to do generation instead. Implement Alyssa's idea, and show the first half-dozen or so sentences generated. ———————————————————————————————————————————————————————————————————————— Implementation skipped. As described in the footnote, these will not be very interesting, for the reason that the grammar is highly recursive, and can generate infinitely long sentences. To fix this problem we can choose, before anything else, the length of the sentence we wish to generate, and then generate sentences of that length until no more can be found. Then the limit will be increased and all the sentences with one more word will be generated, and so on. This is an infinite stream, but as before with the infinite stream of integer triples, any given sentence, however long, will eventually be produced. (define (generate-sentences) (let ((sentence-length (an-integer-starting-from 3)) (words-generated 0)) (define (parse-word words) (require (< words-generated sentence-length)) (an-element-of words)) (define (parse-sentence ...)) ... the rest of the parsers should be redefined here, so as to use the new 'parse-word' ... (parse-sentence)))