小猫猫今天脑洞大开,把国学经典《弟子规》,翻译成了编程代码。
// 弟子规, 圣人训
document.name = "Rules for being a student and child";
document.author = "Confucius";
// 首孝悌, 次谨信
Rules.push("Care about your parents and siblings.");
Rules.push("Be careful and honest with others.");
// 泛爱众, 而亲仁
people.forEach(function(person) {
you.ShareLoveWith(person);
if (person.HasKindHeart()) {
you.MoveCloserTo(person);
}
});
// 有余力, 则学文
if (you.remainingEffort > 0) {
you.Learn("Other skills");
}
// 父母呼, 应勿缓
parents.call = function(event) {
setTimeout(you.Answer(parents), 0);
};
// 父母命, 行勿懒
parents.command = function(event) {
you.action = input;
setTimeout(you.DealWith(event), 0);
};
// 父母教, 须敬听
parents.teach = function(event) {
you.gesture = "modest";
you.ListenTo(parents);
};
// 父母责, 须顺承
parents.blame = function(event) {
you.gesture = "respect";
you.Obey(parents);
};
// 冬则温, 夏则凊
switch(GetCurrentSeason()) {
var obj = parents.bed;
case("winter"):
you.Warm(obj);
break;
case("summer"):
you.Cool(obj);
break;
}
// 晨则省, 昏则定
you.OnWakeUp = function() {
this.Check(parents);
this.Say("Hello", parents);
};
you.OnComeBack = function() {
this.Report(parents, report);
parents.emotion = "relax";
};
// 出必告, 反必面
you.LeaveHome = function() {
this.Report(parents, time, place);
setTimeout(OnComeBack, time);
};
// 居有常, 业无变
you.Live = function(event) {
do {
this.Act("Normal");
parents.emotion = "relax";
} while (this.isAlive());
};
you.OnChange = function(event) {
this.Follow(rules);
};
今天暂时翻译这么多,可能不是很流畅。
|