2007年5月5日星期六

文明4名言集(zz)

Agriculture 农业
Oh farmers, pray that your summers be wet and your winters clear. - Virgil
农夫们啊, 我为你们祈求夏季多雨, 冬季干燥. - 维吉尔

Animal Husbandry 家畜驯养
Blessed shall be the fruit of thy cattle, the increase of thy kine, and the flocks of thy sheep. - The Bible, Deut. 28:4
汝家牲畜之生养, 牛犊之成长, 羊群之繁盛, 都必蒙赐福. - 圣经·申命记 28:4

Archery 弓箭
Do not throw the arrow which will return against you. - Kurdish Proverb
不要轻易放箭, 如果箭会射向你自身 - 库尔德谚语

Bronze Working 青铜器
It is entirely seemly for a young man killed in battle to lie mangled by the bronze spear. In his death all things appear fair. - Homer
带着青铜矛的剌伤战死沙场, 是一位年轻人最恰当的归宿. 牺牲让他的一切都充满荣光. - 荷马

Fishing 渔业
Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. - Lao Tzu
授人以鱼, 不如授人以渔. - 老子

Horseback Riding 骑术
If you speak the truth, have a foot in the stirrup.” - Turkish proverb
讲真话的人应该一只脚踩在马镫里. - 土耳其谚语

Hunting 捕猎
If you chase two rabbits, you will lose them both. - Native American Saying
同时追逐两只野兔, 你将一无所获. - 美洲原住民谚语

Masonry 石工术
It is from their foes, not their friends, that cities learn the lesson of building high walls. - Aristophanes
是敌人而不是朋友教育我们: 城市需要建造高墙 - 阿里斯托芬

Meditation 冥想学
Meditation brings wisdom; lack of meditation leaves ignorance. Know well what leads you forward and what holds you back. - The Buddha
静坐冥想带来智慧; 缺少冥想必定无知. 要明白是什么使人前行, 又是什么使人后退 - 佛陀

Mining 采矿
The man who moves a mountain begins by carrying away small stones. - Confucius
人心齐, 泰山移. - 中国古语 (与原文不同, 但找不到孔子原话)

Monotheism 一神论
I am the Lord thy God. Thou shalt have no other gods before Me. - The Bible, Exodus
我是耶和华, 你的神. 除了我以外, 你不可有别的神 - 圣经·出埃及记

Mysticism 神秘论
Nature herself has imprinted on the minds of all the idea of God.- Cicero
自然的一切都有神明的意志留下的烙印. - 西塞罗

Polytheism 多神论
Not at all similar are the race of the immortal gods and the race of men who walk upon the earth. - Homer
诸神在天界永生, 人类在地上行走, 两者全然不同. - 荷马

Pottery 制陶
Hath not the potter power over the clay, to make one vessel unto honor, and another unto dishonor? - The Bible, Romans
匠人难道没有权柄, 从一团泥里拿一块作成贵重的器皿, 又拿一块作成卑贱的器皿么? - 圣经·罗马书

Priesthood 祭司制度
The Lord bless you and keep you; the Lord make His face to shine upon you and be gracious to you; the Lord lift up His countenance upon you and give you peace. - The Bible, Numbers
愿主赐福给你, 保护你. 愿主使他的脸光照你, 赐恩给你. 愿主向你仰脸, 赐你平安. - 圣经·民数记

Sailing 航海
You can’t direct the wind, but you can adjust your sails. - Unknown
你不能控制风向, 但可以调整风帆. - 无名氏

The Wheel 轮子
Put your shoulder to the wheel. - Aesop
用你的肩膀把车轮扛起来. - 伊索

Writing 文字
True glory consists in doing what deserves to be written; in writing what deserves to be read. - Pliny the Elder
真正的荣耀在于做值得写的; 写值得看的 - 老普林尼

Alphabet 字母表
Words have the power to both destroy and heal. When words are both true and kind, they can change our world. - The Buddha
词句有毁灭之力, 亦有拯救之能. 词句既真且善, 便可改变世界. - 佛陀

Calendar 历法
For everything there is a season and a time for every purpose under heaven. - Ecclesiastes
万物皆有定期, 凡事都有定时. - 圣经·传道书

Code of Laws 法典
To bring about the rule of righteousness in the land, so that the strong should not harm the weak. - Hammurabi’s Code; Prologue
让正义的统治降临大地, 使强者不能欺凌弱者. - 汉谟拉比法典, 序言

Compass 罗盘
The wisest men follow their own direction. - Euripides
有智慧的人自己选择方向 - 欧里庇得斯 (希腊诗人)

Construction 建筑结构学
And on the pedestal these words appear: ’My name is Ozymandias, king of kings: Look on my works, ye Mighty, and despair!’ Nothing beside remains. - Percy Bysshe Shelley
在那石座上还有这样的铭记: ’我是奥西曼德斯, 众王之王: 那些所谓强悍者呵, 谁能和我的业绩相比!’ - 珀西·拜什·雪莱

Currency 货币制度
Everything is worth what its purchaser will pay for it. - Publius Syrus
物品的价值就是买者愿支付的价格. - 帕布利乌斯·塞鲁斯 (叙利亚作家)

Drama 戏剧
All the world’s a stage, And all the men and women merely players. They have their exits and their entrances; And one man in his time plays many parts.- William Shakespeare
全世界是一个巨大的舞台, 所有红尘男女均只是演员罢了, 上场下场各有其时, 每个人一生都扮演着许多角色. - 威廉·莎士比亚

Iron Working 铁器
You should hammer your iron when it is glowing hot. - Publius Syrus
趁热打铁才能成功. - 帕布利乌斯·塞鲁斯 (叙利亚作家)

Literature 书面文献
Some books are to be tasted, others to be swallowed, and some few to be chewed and digested. - Sir Francis Bacon
书有可浅尝者, 有可吞食者, 少数则须咀嚼消化。 - 弗朗西斯·培根爵士

Mathematics 数学
If in other sciences we should arrive at certainty without doubt and truth without error, it behooves us to place the foundations of knowledge in mathematics. - Roger Bacon
要使其他学科的内容准确无疑和真实无误, 就应当将数学作为所有知识的基础. - 罗杰·培根 (中世纪英国科学家)

Metal Casting 金属铸造
And them that take the sword shall perish by the sword. - The Bible, Matthew
凡动用刀剑者, 必死于刀剑之下. - 圣经·马太福音

Monarchy 君主制
A multitude of rulers is not a good thing. Let there be one ruler, one king. - Herodotus
统治者过多全无益处. 一国应当只有一位统治者, 一位君王. - 希罗多德

Banking 银行业
Banking establishments are more dangerous than standing armies. - Thomas Jefferson
银行系统比正规军队更难对付. - 托马斯·杰弗逊

Civil Service 文官制度
The bureaucracy is expanding to meet the needs of the expanding bureaucracy - Unknown
官僚机构的扩大是为了适应官僚机构扩大的需要 - 无名氏

Divine Right 君权神授论
I am the state. - Louis XIV
朕即国家. - 路易十四

Engineering 工程学
A designer knows he has achieved perfection not when there is nothing left to add, but when there is nothing left to take away. - Antoine de Saint- Exupry
设计师知道自己的作品何时达到完美: 不是当没有更多的部分可以增加时, 而是当没有更多的部分可以删减时. - 安托瓦尼·德·圣艾修伯里 (法国飞行家)

Feudalism 封建制度
I will to my lord be true and faithful, and love all which he loves and shun all which he shuns. - Anglo Saxon Oath of Fealty
我将真诚待奉我的领主, 爱他所爱的, 恶他所恶的. - 盎格鲁-撒克逊效忠誓词

Guilds 行会
People of the same trade seldom meet together, even for merriment and diversion, but the conversation ends in a conspiracy against the public. - Adam Smith
同一行业的人聚会, 即便是为了嬉戏娱乐, 最终必定以针对公众的密谋而结束 - 亚当·斯密

Machinery 机械
A god from the machine - Menander
机器之中有神灵 - 米南德尔 (希腊诗人)

Music 音乐
If music be the food of love, play on. - William Shakespeare
如果音乐是爱情的食粮, 那么请你继续演奏下去. - 威廉·莎士比亚

Optics 光学
One doesn’t discover new lands without losing sight of the shore. - Andre Gide
不想远离海岸线, 就别想发现新陆地. 安德烈·纪德 (法国小说家)

Paper 造纸
I cannot live without books - Thomas Jefferson
没有书我就不能活 - 托马斯·杰弗逊

Philosophy 哲学
I have gained this by philosophy: that I do without being commanded what others do only from fear of the law. - Aristotle
我通过哲学了解了这一点: 我行事是出于自觉, 他人行事只是因为害怕法律 - 亚里士多德

Theology 神学
Two cities have been formed by two loves: the earthly by the love of self; the heavenly by the love of God. - St. Augustine
两种爱造就了两座城: 自爱所造的尘世之城; 神爱所造的天界之城. - 圣奥古斯丁

Astronomy 天文学
Astronomy compels the soul to look upwards and leads us from this world to another. - Plato
天文学吸引人们仰望上苍, 引导我们了解其他的世界. - 柏拉图

Chemistry 化学
Chemistry means the difference between poverty and starvation and the abundant life. - Robert Brent
化学的产生意味着穷困饥馑与富足安康的分野. - 罗伯特·布伦特

Constitution 宪法
No freeman shall be taken, imprisoned, or in any other way destroyed, except by the lawful judgment of his peers. - The Magna Carta
任何自由人, 未经其他自由人之依法判决, 皆不得被逮捕, 监禁, 或加以任何其他损害. - 英国大宪章

Corporation 公司制
Corporation, n. An ingenious device for obtaining individual profit without individual responsibility. - Ambrose Bierce
公司, 名词. 一种精妙的机构, 能带来个人收益, 而无须个人负责. - 安布罗斯·比尔斯 (美国作家)

Democracy 民主主义
It has been said that democracy is the worst form of government except all the others that have been tried. - Winston Churchill
如果不算其它所有曾经实行过的政体, 民主制度就是最糟糕的一种政体. - 温斯顿·丘吉尔

Economics 经济学
Compound interest is the most powerful force in the universe. - Albert Einstein
复息利率是宇宙中最强大的力量. - 阿尔伯特·爱因斯坦

Education 教育学
There is no wealth like knowledge, no poverty like ignorance. - Ali ibn Abi-Talib
知识即财富, 无知即贫穷. - 阿里·伊本·阿比-塔里布 (阿拉伯诗人)

Gunpowder 火药
You can get more of what you want with a kind word and a gun than you can with just a kind word. - Al Capone
说好话的同时拿把枪, 比光说好话能更能得到你想要的. - 艾尔·卡彭 (芝加哥黑帮首领)

Liberalism 自由主义
Any society that would give up a little liberty to gain a little securitywill deserve neither and lose both. - Benjamin Franklin
任何社会如果宁愿放弃一些自由以获得一些安全, 就既不会拥有自由, 也不会获得安全 - 本杰明·富兰克林

Military Tradition 军事制度
Victorious warriors win first and then go to war, while defeated warriors go to war first and then seek to win. - Sun-Tzu
是故胜兵先胜而后求战, 败兵先战而后求胜. - 孙子

Nationalism 民族主义
A man does not have himself killed for a half-pence a day or for a petty distinction. You must speak to the soul in order to electrify him. - Napoleon Bonaparte
一个人不会为了每天半个铜币和一点荣誉而付出自己的生命, 你必须鼓动他的灵魂才能激发他的斗志. - 拿破仑·波拿巴

Printing Press 印刷机
What gunpowder did for war, the printing press has done for the mind. - Wendell Phillips
正如火药改变了战争的形式, 印刷机也改变了思想传播的方式. - 温德尔·菲利浦斯(美国废奴运动领袖)

Replaceable Parts 可更换部件
The whole is more than the sum of its parts. - Aristotle
整体大于部分之和. - 亚里士多德

Rifling 膛线
Political power grows out of the barrel of a gun. - Mao Zedong
枪杆子里出政权. - 毛泽东

Artillery 火炮
Artillery adds dignity to what would otherwise be a vulgar brawl. - Frederick the Great
火炮提供一种尊严的手段, 可以用来代替粗俗的怒骂. - 腓特烈大帝

Assembly Line 生产流水线
People can have the Model T in any color - so long as it’s black. - Henry Ford
顾客可以选择任何颜色的 T 型车 - 只要是黑色的. - 亨利·福特

Biology 生物学
It is not the strongest of the species that survive, but the one most responsive to change. - Charles Darwin
物竞天择, 适者生存. - 查尔斯·达尔文

Combustion 内燃机
Everything in life is somewhere else, and you get there in a car. - E. B.White
要想找寻生活中的一切, 你须乘坐一辆小车前往. - 埃尔文·布鲁克斯·怀特 (美国作家)

Communism 共产主义
When I give food to the poor, they call me a saint. When I ask why the poor have no food, they call me a communist. - Dom Helder Camara
当我给穷人食物, 他们说我是圣徒, 当我问穷人为何没食物, 他们说我是共产党. - 多姆·赫尔德·卡马拉 (巴西大主教)

Electricity 电学
We will make electricity so cheap that only the rich will burn candles. - Thomas Edison
我们要让电变得无比便宜, 以至于只有富人才会点蜡烛. - 托马斯·爱迪生

Fascism 法西斯主义
The great masses of the people… will more easily fall victims to a big lie than to a small one. - Adolf Hitler
人民大众… 更容易被大的谎言, 而不是小的谎言所欺骗. - 阿道夫·希特勒

Fission 核裂变
If the radiance of a thousand suns were to burst at once into the sky, that would be like the splendor of the Mighty One… I am become Death, the Shatterer of Worlds. - J. Robert ppenheimer, quoting ”The Bhagavad Gita”
如果一千颗太阳同时在天空发光, 就能彰显造物主的荣耀… 我成为了死神, 世界的毁灭者. - 罗伯特·奥本海默, 引自 ”博伽梵歌”

Industrialism 产业主义
There is one rule for the industrialist and that is: Make the best quality of goods possible at the lowest cost possible, paying the highest wages possible. - Henry Ford
工业家必须遵守的规矩: 尽可能提高质量, 尽可能降低成本, 尽可能提高薪水. - 亨利·福特

Medicine 医学
As to diseases make a habit of two things - to help, or at least, to do no harm. - Hippocrates
对于病人, 有两件事要作为惯例 - 一是要救治之, 二是至少不要伤害之. - 希波克拉底 (医学之父)

Physics 物理学
To every action there is always opposed an equal reaction. - Isaac Newton
每个作用力必定对应一个同样大小的反作用力. - 艾萨克·牛顿

Railroad 铁路
I fooled you, I fooled you, I got pig iron, I got pig iron, I got all pig iron. - Lonnie Donegan, ”Rock Island Line”
我骗了你, 我骗了你, 我运的是铁, 我运的是铁, 我运的全都是生铁. - 罗尼·多内甘, ”岩石岛铁路”(蓝调歌手)

Scientific Method 科学方法
I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use. - Galileo Galilei
我不认为神给予我们感觉, 理性和智慧, 是为了让我们弃之不用. - 伽利略奥·伽利略

Steam Power 蒸汽机
You would make a ship sail against the winds and currents by lighting a bon-fire under her deck? I have no time for such nonsense. - Napoleon, on Robert Fulton’s Steamship
你说你造的船凭甲板下面放把火就能顶风逆水航行? 我没工夫听这种胡说八道. - 拿破仑, 评论罗伯特·富尔顿的汽船

Steel 炼钢
Before that steam drill shall beat me down, I’ll die with my hammer in my hand. - from ”John Henry, the Steel-Driving Man”
若要气钻胜过我, 除非我死把锤扔. - 摘自 ”约翰·亨利, 钢铁一般的人” (美国民谣)

Composites 复合材料
The whole is greater than the sum of its parts. - Aristotle
整体大于部分之和. - 亚里士多德

Computers 电子计算机
Never trust a computer you can’t throw out a window. - Steve Wozniak
不要信赖那些大到不能扔出窗子的计算机. - 斯蒂夫·沃兹尼亚克 (苹果电脑创始人之一)

Ecology 生态学
We do not inherit the earth from our ancestors, we borrow it from our children - Native American Song
我们的土地并非自祖先手中所继承的, 而是从子孙那里所借取的. - 美洲原住民谚语

Fiber Optics 光纤
There is a single light of science, and to brighten it anywhere is to brighten it everywhere. - Isaac Asimov
科学之光只有一束, 在任何一处闪耀就可照亮一切. - 艾萨克·阿西莫夫

Flight 航空
For once you have tasted flight you will walk the earth with your eyes turned skywards, for there you have been and there you will long to return. - Leonardo Da Vinci
一旦尝试过飞翔的滋味, 你就会时刻仰视天空, 渴望再次回到那里. - 列奥纳多·达·芬奇

Fusion 核聚变
Any sufficiently advanced technology is indistinguishable from magic. - Arthur C. Clarke
任何一种足够新颖的技术看起来都象是魔法. - 亚瑟·克拉克 (美国科幻作家)

Genetics 遗传学
Soon it will be a sin for parents to have a child which carries the heavy burden of genetic disease. - Bob Edwards
将来如果有父母生下携带严重遗传疾病的孩子, 就是犯罪行为. - 鲍勃·爱德华兹 (美国社会学家)

Mass Media 大众传媒
The only thing worse than being talked about is not being talked about. - Oscar Wilde
比遭人议论更糟糕的唯一一件事就是无人议论. - 奥斯卡·王尔德

Plastics 塑料
I just want to say one word to you. Just one word: plastics. - Calder Willingham, The Graduate
我只想对你说一个词. 就一个词: 塑料. - 卡德尔·威灵汉姆, 电影 ”毕业生”

Radio 无线电
Then one fine mornin’ she puts on a New York station. You know her life was saved by Rock ’n' Roll. - The Velvet Underground, ”Rock And Roll”
在某天清晨她打开一个纽约电台. 你知道拯救了她生命的就是摇滚 - 地下丝绒, ”摇滚” (美国摇滚乐队)

Refrigeration 致冷
Tell me what you eat, and I will tell you what you are. - Anthelme Brillat- Savarin
告诉我你喜欢吃什么, 我就能了解你的为人 - 安特姆·布里亚特·萨瓦伦 (法国美食家)

Robotics 机器人
The real problem is not whether machines think, but whether men do. - B.F.Skinner
真正的问题不是机器能否思考, 而是人能否思考. - 史金那 (美国新行为主义心理学家)

Rocketry 火箭
The Earth is the cradle of the mind, but one cannot eternally live in a cradle. - Konstantin E. Tsiolkovsky
地球是人类的摇篮, 但人不能总是躺在摇篮里面. - 康斯坦丁·齐奥尔科夫斯基 (运载火箭之父)

Satellites 人造卫星
Beep…beep…beep…beep… - Sputnik I
哔…哔…哔…哔… - 伴星一号 (第一颗人造卫星)

Future Tech 未来科技
The future will be better tomorrow. - Dan Quayle
未来将是更美好的明天. - 丹·奎尔 (美国副总统)

2007年4月22日星期日

我们是一个Team

August 9th, 2006 Wednesday Sunny

算起来,在这里已经待了三个周了,学到了很多东西,除了技术上的,更多的是工作方式,尤其是团队合作。

程序员每天该做的事(zz)

2006.03.15 来自:CSDN 选自Mailbomb 的blog

  程序员每天该做的事

1、总结自己一天任务的完成情况

最好的方式是写工作日志,把自己今天完成了什么事情,遇见了什么问题都记录下来,日后翻看好处多多

2、考虑自己明天应该做的主要工作

把明天要做的事情列出来,并按照优先级排列,第二天应该把自己效率最高的时间分配给最重要的工作

3、考虑自己一天工作中失误的地方,并想出避免下一次再犯的方法

出错不要紧,最重要的是不要重复犯相同的错误,那是愚蠢

4、考虑自己一天工作完成的质量和效率能否还能提高

一天只提高1%,365天你的效率就能提高多少倍你知道吗? (1+0.01)^365 = 37 倍

5、看一个有用的新闻网站或读一张有用的报纸,了解业界动态

闭门造车是不行的,了解一下别人都在做什么,对自己能带来很多启示

6、记住一位同事的名字及其特点

你认识公司的所有同事吗?你了解他们吗?

7、清理自己的代码

今天完成的代码,把中间的调试信息,测试代码清理掉,按照编码风格整理好,注释都写好了吗?

8、清理自己的桌面

当日事当日毕,保持清洁干劲的桌面才能让你工作时不分心,程序员特别要把电脑的桌面清理干净

程序员每月该做的事

1、至少和一个同事一起吃饭或喝茶
不光了解自己工作伙伴的工作,还要了解他们的生活

2、自我考核一次
相对正式地考核自己一下,你对得起这个月的工资吗?

3、对你的同事考核一次
你的同事表现怎么样?哪些人值得学习,哪些人需要帮助?

3、制定下月的计划,确定下月的工作重点

4、总结自己工作质量改进状况
自己的质量提高了多少?

5、有针对性地对一项工作指标做深入地分析并得出改进的方案
可以是对自己的,也可以是对公司的,一定要深入地分析后拿出自己的观点来。要想在老板面前说得上话,做的成事,工作上功夫要做足。

6、与老板沟通一次
最好是面对面地沟通,好好表现一下自己,虚心听取老板的意见,更重要的是要了解老板当前关心的重点

程序员每年该做的事

1、年终总结
每个公司都会做的事情,但你真正认真地总结过自己吗?

2、兑现给自己、给家人的承诺
给老婆、儿子的新年礼物买了没有?给自己的呢?

3、下年度工作规划
好好想想自己明年的发展目标,争取升职/加薪、跳槽还是自己出来干?

4、掌握一项新技术
至少是一项,作为程序员一年要是一项新技术都学不到手,那就一定会被淘汰。
掌握可不是看本书就行的,要真正懂得应用,最好你能够写一篇教程发表到你的blog

5、推出一种新产品
可以是一个真正的产品,也可以只是一个类库,只要是你创造的东西就行,让别人使用它,也为世界作点贡献。当然如果真的很有价值,收点注册费也是应该的

6、与父母团聚一次
常回家看看,常回家看看

只有第6条超额完成了。。。。

July 19th, 2006 Wednesday Sunny - 进入细节

实习第六天

继续对付昨天的bug,我需要知道为什么我用来测试A功能的测试程序为什么不能工作。按照同事的说法,我必须要跟踪进入我需要测试的模块,虽然这是一个开发了多年的庞大系统,但是决不能因为看到一大堆细节就害怕了。最后,单步跟踪结果是,原来这个A功能支持就还没有实现,只是有了接口-_-|||只能等了。

不过总算今天的工作并没有白费,通过跟踪实现,我对OpenGL流水线的理解加深了许多。看来以后要多了解细节才行。

虽然面对的是一个庞大的系统,但是只要有耐心,慢慢一步步来,一定还是可以搞清楚他的脉络的。

2007年4月16日星期一

C-mode下用空格代替tab缩进


(add-hook
'c-mode-common-hook
(lambda ()
(set-variable (quote indent-tabs-mode) nil nil)
...

2007年3月12日星期一

第三天

今天风好大,害我骑车上班路上眼睛里进了不少沙子...台风貌似临近了。

今天头过来找我谈了谈,大概了解了我这几天的进度(其实是没有进度,工作环境才刚刚搭建起来)。然后又给我大概讲了一些工作流程的事情,让我了解了不少。更重要的是,告诉我问问题的方式,有问题尽量在周围的同事那里解决,尤其是一些弱智的问题(比如,怎么在opengl里做blending,寒-_-|||)不要随便骚扰总部的同事...记住一点,大家都很忙...看来那篇《提问的智慧》应该好好看看了:-p

另一个问题是看代码,多用跟踪,理解代码是怎么工作的很重要。看代码是我的弱项,应该加强(注:经过这次实习,自己感觉看代码的能力是大大加强了)。

明天回杭州搬电脑。

外面的风还呜呜的吹...睡觉了...


附注:
提问的智慧(中文版)
http://www.linuxforum.net/doc/smartq-grand.html

2007年3月8日星期四

unix2dos in Emacs

参考了这个blog里的实现方式

(defun unix-dos () (interactive)
(let ((current-buffer-file-name buffer-file-name))
(goto-char (point-min))
(while (search-forward "\n" nil t) (replace-match "\r\n"))
(save-buffer)
(kill-buffer nil)
(find-file current-buffer-file-name)))

在Emacs中设置不用tab缩进

(setq indent-tabs-mode nil)

2007年2月21日星期三

批判、理性、宽容

第七章:“说服”

评注:作为被说服者,我们常常要面对各种各样的说服,有时候我们需要保持批判的态度去抵制讨厌的说服。同时,我们也需要从不同的人身上学到新的东西,保持宽容可以让我们更多的思考不同的观点(被说服的过程)。

批判和宽容的极端一面是偏执和天真,理性是让我们保持客观的根本方法。对说服过程的了解,可以让我们知道为什么有时候会处于偏执的状态,从而对合理信息产生自动的(可能是无意的)排斥。在必要的时候,需要保持这样的理性。

define-syntax的实现

(define-sytax foo 
()
(syntax-rules
((foo a b) (+ (car a) b))
))

(foo '(1 2 3) 3)
;; a -> '(1 2 3)
;; b -> 3

这是一个很简单的模型。

pattern (foo a b)可以用来生成一个parser,方法如下
parser_syntax_foo = do
parser_left_par
parser_foo
a <- parser_a -- :: Parser Binding
b <- parser_b -- :: Parser Binding
parser_right_par
return $ a ++ b
-- Binding: 用来描述宏替换时宏参数和替换文本之间对应关系
或者可以封装在Monad中:
parser_syntax_foo = do
parser_left_par
parser_foo
parser_a -- :: Parser ()
parser_b -- :: Parser ()
parser_right_par
...
template (+ (car a) b))
用前面得到的参数对应的替换文本进行替换
...
genCode template
...
其中genCode :: Template -> Parser Expr
Binding已经封装在Monad中

pattern可以生成一个parser的表([Parser ()])用mapM_来跑一遍
于是可以写成

parser_syntax_foo :: Pattern -> Template -> Parser Expr
parser_syntax_foo pattern template = do
mapM_ (genParsers pattern)
genCode template
在顶层的Parser里封装了一个宏函数(foo)和对应的Parser之间的绑定关系。
Parser根据实际遇到的调用进行分派

2007年2月9日星期五

K歌,健身(可怜的肩膀...),乒乓

2007年2月8日星期四

上海实习第二天

July 13th, 2006 Thursday Sunny

工作的第二天,继续昨天的setup环境,build、build再build。强烈的感觉到集群编译环境的重要性。编译太慢了,尤其是这种超大的工程,头疼...

开始逐步体会到了大公司里的所谓模块化了(估计说模式化更恰当)。突然开始觉得还是学校好了,可以自由采用自己喜欢的方式去完成自己的工作(好事?坏事?)。也许以后进一步熟悉以后会好起来吧。

这里的氛围很不错,大家都很容易相处,manager确实非常nice,大家都直呼其名字,感觉距离近了不少。

今天和manager聊了一会,收获蛮大。听了许多关于这个行业的事情,让我对我要做的工作清晰了不少。

总之,昨天显得太拘束了,今天好很多了:)明天还要继续努力

2007年2月6日星期二

听力过了~~~

总算搞定了该死的听力,呵呵,看来看美剧效果还是很明显的,继续多看美剧。算了算听力分数还不算可以,要不是写错了一个单词...

IC & IC

过去,支撑硅谷运转的是IC(集成电路),现在还有IC(Indian and China,印度和中国) 。

昨天听一个搞IC的人说起,今天刚好又在新周刊的《语录》上看到这句话。

2007年2月5日星期一

上海实习第一天

July 12th, 2006 Wednesday Sunny

第一天正式上班,很多东西都很新鲜。先说说对公司的印象吧。首先“***”这个中文名字感觉怪怪的(还是英文名字比较酷)。 早早就来到公司(其实昨天晚上已经骑车过来探路过了),报道之前在休息室和交大和复旦的两个家伙聊了一会,他们都是做asic的,说起来,我完全不懂-_-|||期间进来几个人,其中一个还是那边某个team的leader,但是一点架子没有,感觉让人轻松不少。

完成手续后,到了公司新的office(后来才知道,其实是临时office),一栋全黑的大楼,很酷。还在装修中,味道实在很难闻。

在办公室见到了我们的头,也是面试我的面试官,给人的第一感觉是非常nice,应该是一个不错的上司吧。

接下来是setup工作环境,这一步非常的烦人,好多东西要down下来,等了一天了:(到了晚上7点,抗不住了,明天再来看看吧,希望能跑起来。

同事们都还是非常热心的,感觉非常的不错,刚开始的不自在很快就消失了。要加油了。不过在头面前还是有些拘束的,这一点要改进。

2006.7 上海

实习日记

从今天开始开始发我的实习日记,这段时间算是我人生的一次重大的经历,我的职业道路可能就因此而改变。学到了许多东西;无论做人,做事,还是做技术,对我来说都是重大的提升。重新回顾这段经历,好让我更好的反省我的日常工作的做法,以更高的标准要求自己。

以主线情节为主,略过不重要事件;以感悟为主,略过具体事件。所有出现的人都用名字的第一个字母代替。

文笔不好,很多都是流水帐-_-|||

自我实现预言(self-fullfilling prophecies)

如果我们的观念引导我们做出证实我们观念的行动时,这就成了自我实现预言。

比如:对对方的敌意的判断会导致我们的敌意举动,从而引发对方的敌意行为,进而验证我们的信念;伴侣理想化对方时会更容易保持亲密的关系...

注:宽容,真诚,互相尊重

行为确认(behavioral confirmation):一旦形成错误的社会信念,就可能会引发他人做出某些行为反应以支持这种信念,这种现象叫做行为确认。

注:加上验证性偏见的影响,这种信念会进一步加强...如此形成恶性循环


对自己信念的自我实现,人们通常会实现对自我行动的预测

2007年2月1日星期四

自我妨碍(self-handicapping)

人们会通过给自己设置障碍来阻挠自己的成功,这并不是为了破坏自我,恰恰是为了保护自我。

在此基础上,我们可以通过为将失败归因于一些外在的因素,以此来保护我们的自尊(self-esteem)

Berglas & Jones, 1978年的试验
Drug choice as a self-handicapping strategy in response to noncontingent

注释:
这个结论确实很有意思,仔细想想,在自己身上也发生过。潜意识里确实有这样的想法,与其付出努力而失败,不如不作为。“破罐子破摔”一定程度上也可以通过这个来进行解释。

在行动中获得快乐

如果良好的自我感觉是我们的目标...更加倾向于在压力下追求成功,而不是仅仅在行动中获得快乐。时间久了,如此寻求自尊并不能满足我们对能力、人际关系和自主性的深层次需求...

注释:
不是每个人都能得到他(她)想要的成功,但是每个人都能付出努力。成功是暂时的,但是每个人可以付出的努力确实长久的。享受行动本身带来的快乐,才会真正的感到快乐。

2007年1月30日星期二

ABCDEFG-GFEDCBA

如果你不敢去做,你会找到一个理由...

如果你不敢去做,你会找到一个理由
如果你决定要做,你会找到一个方法

(pbxy@newSMTH)

2007年1月23日星期二

Data Path logic cells

对n-bit的data bus进行运算的logic cell。
输入(bus),输出(bus),控制信号

2007年1月21日星期日

如何在haskell里实现permute(NewSMTH)

发信人: faint (faint), 信区: FuncProgram
标 题: 转载: 如何在haskell里实现permute
发信站: 水木社区 (Thu Jul 27 01:05:22 2006), 站内

[Haskell] String permutation haskell

Sukit Tretriluxana
to haskell
Dear expert Haskellers,

I am a newbie to Haskell and try to write several algorithms with it. One of
them is the string permutation which generates all possible permutations
using the characters in the string. For example, if I say,

permute "abc"

It will return the the result as

["abc","acb","bca","bac","cab","cba"]

And here is the program I came up with.

permute :: String -> [String]
permute str = rotate str len len
where len = length str

rotate :: String -> Int -> Int -> [String]
rotate _ _ 0 = []
rotate s 1 _ = [s]
rotate (ch:chs) len rcnt =
map (\x -> ch : x) (rotate chs (len-1) (len-1))
++
rotate (chs ++ [ch]) len (rcnt-1)

I am more than certain that this simple program can be rewritten to be more
succinct and possibly more efficient using Haskell's features. So I would
like to ask if any of you would kindly show me an example.

Regards,
Ed
_______________________________________________

CHA Reeseo
to haskell

Sorry for my rough English.

How about this? This is just ANOTHER way which is not so
succincter or more efficient than yours. :)

(.^) = (.) . (.) -- (.^) uf bf x y = uf (bf x y)
(.^^) = (.) . (.) . (.) -- (.^^) uf tf x y z = uf (tf x y z)
(^.) = (.) . flip (.) -- (^.) f g = (. f) . g

shuffle :: [a] -> [[a]]
shuffle [] = [[]]
shuffle (x:xs) = concatMap (insertAll x) (shuffle xs) where
insertAll :: a -> [a] -> [[a]]
insertAll e [] = [[e]]
insertAll e (x:xs) = (e:x:xs) : map (x:) (insertAll e xs)

combine, permute :: [a] -> Integer -> [[a]]
combine _ r | r < 0 = error "Zero or more elements should be extracted."
combine _ 0 = [[]]
combine [] _ = []
combine (x:xs) r = map (x:) (combine xs (r - 1)) ++ combine xs r
permute = concatMap shuffle .^ combine

Please note that I'm using different names from yours.
The function "shuffle" above means so-called "full shuffle"
which may be similar to your "permute" function,
and my "combine" and "permute" generate all the cases of
nCr and nPr, respectively.

--
CHA Reeseo
http://www.reeseo.net/

_______________________________________________

Martin Percossi
to Sukit, haskell
Sukit Tretriluxana wrote:
> Dear expert Haskellers,
>
> I am a newbie to Haskell and try to write several algorithms with it.
> One of them is the string permutation which generates all possible
> permutations using the characters in the string.

While I could hardly be called an expert haskeller, here's my version:

permute :: [a] -> [[a]]
permute [] = [[]]
permute list = concat $ map (\(x:xs) -> map (x:) (permute xs)) (take
(length list) (unfoldr (\x -> Just (x, tail x ++ [head x])) list))

HTH
Martin
_______________________________________________

Tomasz Zielonka
to Sukit, haskell
On Tue, Jul 25, 2006 at 09:44:36PM -0700, Sukit Tretriluxana wrote:
> permute :: String -> [String]
> permute str = rotate str len len
> where len = length str
>
> rotate :: String -> Int -> Int -> [String]
> rotate _ _ 0 = []
> rotate s 1 _ = [s]
> rotate (ch:chs) len rcnt =
> map (\x -> ch : x) (rotate chs (len-1) (len-1))
> ++
> rotate (chs ++ [ch]) len (rcnt-1)

Some notes:

Your permute gives 0 permutations for an empty input String, but there
should be 1 - the empty string. Note that 0! == 1

The name "rotate" suggests that this function does less than it actually
does.

Also, your functions could easily work for lists with other types of
values, not only for [Char], but you unneccesarily restrict their types.

> I am more than certain that this simple program can be rewritten to be more
> succinct and possibly more efficient using Haskell's features. So I would
> like to ask if any of you would kindly show me an example.

There are some examples at http://www.haskell.org/hawiki/PermutationExample

Below is my favourite way to compute permutations.

import List

perms [] = [[]]
perms (x:xs) = [ p ++ [x] ++ s | xs' <- perms xs
, (p, s) <- zip (inits xs') (tails xs') ]

It's not too efficient - there are other versions that exhibit better
sharing of list tails, etc. Also, the resulting list is not
lexicographically ordered (when the input one is sorted). But I like the
look of this code.

Best regards
Tomasz
- Show quoted text -
_______________________________________________

Robert Dockins
to Sukit, haskell
On Jul 26, 2006, at 12:44 AM, Sukit Tretriluxana wrote:

[snip]


About the shortest way I can think of, using the good ol' list
monad. This isn't exactly efficient, but there you are...


import Data.List

permute :: String -> [String]
permute [] = [[]]
permute str = do
x <- str
xs <- permute (delete x str)
return (x:xs)



Rob Dockins

Speak softly and drive a Sherman tank.
Laugh hard; it's a long way to the bank.
-- TMBG
- Show quoted text -

_______________________________________________

Martin Erwig
to Robert, haskell

Or using list comprehensions and generalizing the type:


permute :: Eq a => [a] -> [[a]]
permute [] = [[]]
permute xs = [x:ys | x <- xs, ys <- permute (delete x xs)]


Or making it completely polymorphic by replacing delete:


permute :: [a] -> [[a]]
permute [] = [[]]
permute xs = [x:zs | (x,ys) <- expose xs, zs <- permute ys]
where expose xs = step [] xs
step _ [] = []
step ys (x:xs) = (x,ys++xs):step (ys++[x]) xs


--
Martin
- Show quoted text -

_______________________________________________

Sebastian Sylvan
to Sukit, haskell
- Show quoted text -

I like the following definition for simplicity:

perms xs = [x:ps | x <- xs, ps <- perms (xs\\[x])]

It's all quite straightforward, basically take each item in the list,
compute the permutations of the *rest* of the list (i.e. remove the
item from the list) and then put the item in front.

Now, this is pretty inefficient, so let's do some basic algebra here.
Rather than computing the item/rest-of-list pairs in the list
comprhension itself, we first separate it into a function (doing the
exact same thing, for now).

perms xs = [x : ps | (y,ys) <- selections xs, ps <- perms ys]
selections xs = [(x,xs\\[x]) | x <- xs]

So now, this does the same thing. But rather than going through each
item (x) and then computing the rest of the list (x\\[x]) directly, we
simply write a function (selections) which does this for us (i.e.
returns a list of pairs of the item and the rest of the list).

Now, let's rewrite selections in a more efficient way:

selections [] = []
selections (x:xs) = (x,xs) : [(y,x:ys) | (y,ys) <- selections xs]

It's clear that the first (most straightforward) selection we can do
here here is the head and the tail of the list, (x,xs). Now we just
recursively compute the selections of the tail, and re-insert the head
in its rightful position at the front of the list part of each result.

So there you have it. A nice looking and fairly efficient way of
generating permutations, and the steps needed to come up with it.


/S
--

Sebastian Sylvan
+46(0)736-818655
UIN: 44640862
- Show quoted text -
_______________________________________________
javascript:void(0)
发布
Sukit Tretriluxana
to Sebastian, haskell
More options 12:44 pm(16 minutes ago)
Thank you so much for all the responses. They really open my eyes how flexible and powerful Haskell is.

Ed

※ 来源:·水木社区 newsmth.net·[FROM: 24.193.243.*]

Haskell版本的快速排序

From
qsort [] = []
qsort (x:xs) = qsort (filter (<>= x) xs)

List comprehesion
qsort [] = []
qsort (x: xs) = (qsort left_xs) ++ [x] ++ (qsort right_xs)
where
left_xs = [y| y <- xs, y <= x]
right_xs = [y| y <- xs, y > x]
是不是很接近数学描述呢,呵呵

轮滑,游泳,Emacs,Linux。
继续想

IDEA收集

序幕写上“VRMM xx年” - by洪晶
(注:参照高达系列的风格)

小草

K歌
乒乓球,羽毛球,跳舞
吃东西