灯下 登录
计算机科学 / SICP / 4.3.2 Examples of Nondeterministic Programs

Exercise 4.49 · 习题

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.

练习 4.49:Alyssa P. Hacker 对生成有趣的句子比对分析句子更感兴趣。她推断,只需修改 parse-word 过程,让它忽略"输入句子",而始终成功并生成一个合适的词,就可以利用我们为语法分析所构建的程序来完成生成工作。请实现 Alyssa 的想法,并展示最先生成的大约六个句子。