这个惊爆的matlab后门转自豆瓣。有点长,我就只是做了部分的摘录,原文请到来源或者讨论组内参观。!在来源处的下方还有一个matlab 的 “why函数” 的代码——看那像模像样的注释,可能是源码。

>> 1+1
ans =
2
>> why
Pete wanted it that way.
>> why
I told me to.
>> why
A young kid told me to.
>> why
Bill insisted on it.
>> why
For the love of Jack.
>> why
The computer did it.
>> why
Some not very bald very rich system manager wanted it.
>> why
You told the rich system manager.
>> why
Some not excessively rich young and smart hamster obeyed some rich and not very good and good and bald kid.
>> why
Cleve suggested it.
>> why
The engineer told me to.
>> why
I helped all.
>> why
Cleve wanted it.
>> why
Why not?
>> why
To fool some smart and young mathematician.
>> why
A smart and very bald and very terrified bald mathematician obeyed a programmer.
>> why
You helped some mathematician.
>> why
I knew it was a good idea.
>> why
A good and smart and not very rich and rich and young and not very young and bald and not excessively rich and tall and tall and not excessively tall and smart and rich and smart and not excessively terrified and rich and good and not very bald and not very terrified very smart not very rich system manager told me to.
>> why
The bald and tall and young and good and smart and terrified and not very tall and young and bald and not very good and good and rich and not very bald and bald system manager told me to.
>> why
Bill suggested it.
>> why
Pete told me to.
>> why
Some young smart tall system manager insisted on it.
>> why
The not very good and terrified and young and smart and smart and young and not excessively good rich hamster suggested it.
>> why
A smart programmer told me to.
>> why
The customer is always right.
>> why
You insisted on it.
>> why
A system manager obeyed the not very tall mathematician.
>> why
Pete obeyed a engineer.
>> why
They threatened a programmer.
>> why
Joe obeyed a tall mathematician.
>> why
Because the terrified and terrified and rich and rich and smart and very young and good and tall and bald and rich and bald and bald and rich and not very good and very terrified and very tall hamster wanted it.

下面是给出的源码,一个简单的教matlab说话的东西:
function why(n)
%WHY Provides succinct answers to almost any question.
% WHY, by itself, provides a random answer.
% WHY(N) provides the N-th answer.
% Please embellish or modify this function to suit your own tastes.

% Copyright 1984-2002 The MathWorks, Inc.
% $Revision: 5.15 $ $Date: 2002/06/17 13:20:59 $

if nargin > 0, rand(‘state’,n); end
switch fix(10*rand)
case 0, a = special_case;
case {1 2 3}, a = phrase;
otherwise, a = sentence;
end
a(1) = upper(a(1));
disp(a);

%——————

function a = special_case
switch fix(12*rand)
case 0, a = ‘why not?’;
case 1, a = ‘don”t ask!’;
case 2, a = ‘it”s your karma.’;
case 3, a = ‘stupid question!’;
case 4, a = ‘how should I know?’;
case 5, a = ‘can you rephrase that?’;
case 6, a = ‘it should be obvious.’;
case 7, a = ‘the devil made me do it.’;
case 8, a = ‘the computer did it.’;
case 9, a = ‘the customer is always right.’;
case 10, a = ‘in the beginning, God created the heavens and the earth…’;
otherwise,a = ‘don”t you have something better to do?’;
end

function a = phrase
switch fix(3*rand)
case 0, a = ['for the ' nouned_verb ' ' prepositional_phrase '.'];
case 1, a = ['to ' present_verb ' ' object '.'];
otherwise, a = ['because ' sentence];
end

function a = preposition
switch fix(2*rand)
case 0, a = ‘of’;
otherwise, a = ‘from’;
end

function a = prepositional_phrase
switch fix(3*rand)
case 0, a = [preposition ' ' article ' ' noun_phrase];
case 1, a = [preposition ' ' proper_noun];
otherwise, a = [preposition ' ' accusative_pronoun];
end

function a = sentence
switch fix(0)
case 0, a = [subject ' ' predicate '.'];
end

function a = subject
switch fix(4*rand)
case 0, a = proper_noun;
case 1, a = nominative_pronoun;
otherwise, a = [article ' ' noun_phrase];
end

function a = proper_noun
switch fix(8*rand)
case 0, a = ‘Cleve’;
case 1, a = ‘Jack’;
case 2, a = ‘Bill’;
case 3, a = ‘Joe’;
case 4, a = ‘Pete’;
case 5, a = ‘Loren’;
case 6, a = ‘Damian’;
case 7, a = ‘Barney’;
end

function a = noun_phrase
switch fix(4*rand)
case 0, a = noun;
case 1, a = [adjective_phrase ' ' noun_phrase];
otherwise, a = [adjective_phrase ' ' noun];
end

function a = noun
switch fix(6*rand)
case 0, a = ‘mathematician’;
case 1, a = ‘programmer’;
case 2, a = ‘system manager’;
case 3, a = ‘engineer’;
case 4, a = ‘hamster’;
case 5, a = ‘kid’;
end

function a = nominative_pronoun
switch fix(5*rand)
case 0, a = ‘I’;
case 1, a = ‘you’;
case 2, a = ‘he’;
case 3, a = ‘she’;
case 4, a = ‘they’;
end

function a = accusative_pronoun
switch fix(4*rand)
case 0, a = ‘me’;
case 1, a = ‘all’;
case 2, a = ‘her’;
case 3, a = ‘him’;
end

function a = nouned_verb
switch fix(2*rand)
case 0, a = ‘love’;
case 1, a = ‘approval’;
end

function a = adjective_phrase
switch fix(6*rand)
case {0 1 2},a = adjective;
case {3 4}, a = [adjective_phrase ' and ' adjective_phrase];
otherwise, a = [adverb ' ' adjective];
end

function a = adverb
switch fix(3*rand)
case 0, a = ‘very’;
case 1, a = ‘not very’;
otherwise, a = ‘not excessively’;
end

function a = adjective
switch fix(7*rand)
case 0, a = ‘tall’;
case 1, a = ‘bald’;
case 2, a = ‘young’;
case 3, a = ‘smart’;
case 4, a = ‘rich’;
case 5, a = ‘terrified’;
otherwise, a = ‘good’;
end

function a = article
switch fix(3*rand)
case 0, a = ‘the’;
case 1, a = ‘some’;
otherwise, a = ‘a’;
end

function a = predicate
switch fix(3*rand)
case 0, a = [transitive_verb ' ' object];
otherwise, a = intransitive_verb;
end

function a = present_verb
switch fix(3*rand)
case 0, a = ‘fool’;
case 1, a = ‘please’;
otherwise, a = ‘satisfy’;
end

function a = transitive_verb
switch fix(10*rand)
case 0, a = ‘threatened’;
case 1, a = ‘told’;
case 2, a = ‘asked’;
case 3, a = ‘helped’;
otherwise, a = ‘obeyed’;
end

function a = intransitive_verb
switch fix(6*rand)
case 0, a = ‘insisted on it’;
case 1, a = ‘suggested it’;
case 2, a = ‘told me to’;
case 3, a = ‘wanted it’;
case 4, a = ‘knew it was a good idea’;
otherwise, a = ‘wanted it that way’;
end

function a = object
switch fix(10*rand)
case 0, a = accusative_pronoun;
otherwise, a = [article ' ' noun_phrase];
end

本文由 严酷的魔王 创作,转载或引用前请联系我们

相关文章:

  1. 黎曼假设之歌:Zeta函数的零点在哪里?
  2. NOIP实用算法 7.分治
  3. 让WordPress保留段首空格的插件
  4. Google Code Jam 2010 尝鲜
  5. Yesterday Once More 非官方简体中文正式版

标签:, ,

2009年5月1日 星期五

留下您的足迹

2009 f(Program,Poet)=Programet.
Powered by Wordpress. Theme by Pharmacy Drugs and LastLeaf.