Chinaunix首页 | 论坛 | 博客
  • 博客访问: 346158
  • 博文数量: 105
  • 博客积分: 2730
  • 博客等级: 少校
  • 技术积分: 1110
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-20 12:09
文章分类

全部博文(105)

文章存档

2013年(3)

2012年(2)

2011年(36)

2010年(34)

2009年(6)

2008年(20)

2007年(4)

分类: PHP

2011-10-31 21:13:11

人类毁灭自己的技术在20世纪已经发明完了, 即使是电影,小说,故事.
我们也来学一学毁灭所有程序员的语言吧.



原文节选自Common Lisp: A Gentle Introduction to Symbolic Computation (Addison-Wesley / Benjamin Cummings, 1990),  作者是David S. Touretzky,CMU的一名教授.
这本书在外国也早已经绝版了,内容循序渐进,我读起来的感觉非常好.

中文为自己翻译的,如有不周详的地方请谅解.
...
"I had a most curious dream," the dragon said. "It was a recursive dream, in fact. Would you like to hear about it?"
"我做了一个非常有趣的梦," 龙说道. "实际上这是一个递归的梦. 你想听听吗?"

Martin was stunned to find the dragon in something resembling a friendly mood. He forgot all about the alchemist’s latest problem. "Yes, please do tell me about your dream," he said.
龙居然对他很友善, 他十分惊讶, 忘记了要问的问题. "好的,请告诉我你做的梦," 他说.

"Very well," began the dragon. "Last night I was looking at a long loaf of bread, and I wondered how many slices it would make. To answer my question I actually went and cut one slice from the loaf. I had one slice, and one slightly shorter loaf of bread, but no answer. I puzzled over the problem until I fell asleep."
"很好," 龙说, "昨天夜里我看到了一个非常长的面包, 我很想知道他能切成几片. 为了得到答案,我亲自跑到面包前面, 切了一片面包下来, 看着这一片面包和剩下的一大条面包,我觉得很困惑,然后不知不觉我就睡着了."

"And that’s when you had the dream?" Martin asked.
"睡着后你做了什么梦呢?" 马丁问道.

"Yes, a very curious one. I dreamt about another dragon who had a loaf of bread just like mine, except his was a slice shorter. And he too wanted to know how many slices his loaf would make, but he had the same problem I did. He cut off a slice, like me, and stared at the remaining loaf, like me, and then he fell asleep like me as well."
"是的,依然是非常有意思的一个梦. 我梦到了另一条龙,他也有一条面包,只不过那个面包比我的短一片的长度. 他也想知道他的面包能切多少片,但是他遇到了和我相同的问题,他切下来一片, 和我一样, 然后盯着剩下的一大截面包, 和我一样, 然后也像我一样睡着了."

"So neither one of you found the answer," Martin said disappointedly.  "You don’t know how long your loaf is, and you don’t know how long his is either, except that it’s one slice shorter than yours."
"那么你们谁都没有得到答案," 马丁很失望地说. "你不知道你的面包多长, 你也不知道他的多长, 你只知道他的比你的短一片."

"But I’m not done yet," the dragon said. "When the dragon in my dream fell asleep, he had a dream as well. He dreamt about—if you can imagine this—a dragon whose loaf of bread was one slice shorter than his own loaf.  And this dragon also wanted to find out how many slices his loaf would make, and he tried to find out by cutting a slice, but that didn’t tell him the answer, so he fell asleep thinking about it."
"不过我还没说完," 龙说. "当我梦中的龙睡着, 他也做了一个梦. 他梦到了--如果你可以想象--一只龙和一个和一条比他小一片的面包. 而且那条龙也想知道他的面包能切多少片, 他切了一片下来, 然后不知道结果, 也睡着了."

"Dreams within dreams!!" Martin exclaimed. "You’re making my head swim. Did that last dragon have a dream as well?"
"梦中的梦!!" 马丁兴奋了. "你让我的脑子转动了. 是不是最后的那只也做了梦?"

"Yes, and he wasn’t the last either. Each dragon dreamt of a dragon with a loaf one slice shorter than his own. I was piling up a pretty deep stack of dreams there."
"是的, 而且他也不是最后一个. 每个龙梦到了一个龙带着一个比他更短一片的面包. 我垒起了好深的一个梦的栈."

"How did you manage to wake up then?" Martin asked.
"你怎么叫醒他们?" 马丁问道.

"Well," the dragon said, "eventually one of the dragons dreamt of a dragon whose loaf was so small it wasn’t there at all. You might call it ‘the empty loaf.’ That dragon could see his loaf contained no slices, so he knew the answer to his question was zero; he didn’t fall asleep.
"是这样," 龙说, "最终有一只龙梦到了一只带着非常非常短的面包的龙,那个面包根本算不上一片. 你可以称它' 空面包'. 所以那条龙知道他剩下的那部分的答案是0, 而且他没睡着."

"When the dragon who dreamt of that dragon woke up, he knew that since his own loaf was one slice longer, it must be exactly one slice long. So he awoke knowing the answer to his question.
"当梦到那条龙的龙醒了,他知道他梦的龙的答案是0, 而且他知道他自己的面包比那个龙的面包长1,所以他的面包长度就是1. 因此他知道了他的答案,他满意地醒了."

"And, when the dragon who dreamt of that dragon woke up, he knew that his loaf had to be two slices long, since it was one slice longer than that of the dragon he dreamt about. And when the dragon who dreamt of him woke up...."
"然后, 当梦到这条龙的龙醒了,他知道了自己的面包是2片长, 因为他的面包比梦中的那个龙的面包长1. 当梦到这只龙的龙再醒了以后......"

"I get it!" Martin said. "He added one to the length of the loaf of the dragon he dreamed about, and that answered his own question. And when you finally woke up, you had the answer to yours. How many slices did your loaf make?"
"我知道了!" 马丁说. "他把梦到的龙得到的答案加1, 就得到了自己的答案. 最后你醒的时候, 你就得到自己的答案. 你的面包有多少片?"

"Twenty-seven," said the dragon. "It was a very long dream."
"27," 龙说. "这是一个好长好长的梦啊."


阅读(1335) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~