This article is from the WeChat public account: QbitAI , author: chestnuts, Xiao investigation, the original title:” alas Calls Xi! Classical Chinese can also be programmed! This year’s most popular language is also “, the picture from: worm

Classmate, do you know how to output “Hello World” in classical Chinese?

Please keep your eyes open here:

The output on the right

I have a word. “‘ Ask the world well. ’”. Book of.

Why is it printed three times? Just because there is a for loop, write “Being” A “all over … Yunyun”. A is equal to three, so ask three times.

This exaggerated classical Chinese programming language comes from CMU undergraduate student Huang Lingdong. Can be compiled intoJavascript can also be compiled into Python, and the editor (IDE) can be played directly.

The project’s arts and sciences have blossomed. It has already received 3,000 stars on GitHub, and everyone around the audience has something to say.

For example, the talent of jealous teenagers:

For example, point in the future:

Mr. Liu Qun, a researcher at the Chinese Academy of Sciences also lamented:

At the moment, I will wait to see the film and explore what kind of essence of the world is hidden in this language.

Classical programming “black words”

Huang Lingdong should have read the Book of Changes. After all, Book of Changes is the earliest ancient book on binary. He used the yin and yang of the Yijing to represent 0 and 1 in Boolean variables.

The “I Have” series is used for definition:

I have a number that defines an int variable; I have a definition that defines a Boolean variable; I have a statement that defines a string; I have a technique that defines a function; I have a column that defines an array.

In general programming, there are if, while, and for loop judgments. Classical Chinese programming is endlessly changing in this matter. The following is a judgment sentence written in classical Chinese:

If three Buddhas are greater than five. I have to “take it for granted”. If not. I have got “” Strange “” too.

The translation is:

if (3 <= 5) {return "of of course"} else {return "no way"}

MaybeYou may think that if ... else ... statements are too verbose in classical Chinese, but the commonly used for loops are more concise in classical Chinese.

is a hundred times. ⋯⋯ Yunyun.

It means:

for (var ii = = 0; <100; i ++) {{...}

If you need to determine whether a certain variable human is in the world, we generally use for (var human of world) This usage of can be confusing, while the expression of classical Chinese is closer to the understanding of ordinary people.

Every "person" in "world". ⋯⋯ Yunyun.

There is the Book of Changes in the ancient times, and Jin Yong's novels today. When demonstrating the definition of the function, the student Huang made another skin:

I have a technique. The name is called "Six-pulse Divine Sword". Desire is art. You must get six. Said "A". Said "B." Said "C". Said "ding". Said "penter". Said "self" is a line of art. Xun is also known as the "six-pulse magic sword".

Here Huang defines the function name as "Six-veined Excalibur". This function has a total of six inputs.

funcion f (a, b, c, d, e, f) {…}

There are more fun function definitions:

How to Program in Classical Chinese

After reading the basic syntax of classical Chinese programming, let's see how to use it to solve some basic problems. For example, to find prime numbers up to 100, we will use an "Esie Sieve" (Sieve of Eratosthenes) algorithm:

Look at the results:

Two. three. Fives. Seven. Eleven. thirteen. Seventeen. Nineteen. twenty-three. Twenty-nine. thirty-one. thirty-seven. forty one. forty three. forty seven. fifty three. fifty-nine. sixty one. sixty seven. seventy one. seventy three. seventy-nine. eighty three. Eighty-nine. Ninety-seven

Do you understand what it means? The compiler translates into JavaScript:

var AI1SHI4SHAI1 = = () => 0; AI1SHI4SHAI1 = function (JIA3) {var var3 YAN3 = = []; for var (_rand4 == 0) ; _Rand4 ++) {yan3.push (true); var var _ans154 = JIA3 / 2;var JIA3BAN4 = _ans154; var WU4 = 2; while (true) {if (WU4 == JIA3BAN4) {break;}; var XU1_ = 2; while (true) {if (XU1_ == JIA3BAN4) {break;}; var _ans155 = wU4 * XU1_; var HE2 = _ans155; if (HE2 <= jIA3) {yAN3 [HE2 - 1] = false;} else {break;}; var _ans156 = 1 + XU1_; XU1_ = _ans156;}; var _ans157 = 1 + WU4; WU4 = = _ans157;); var ZHU1SU4 = []; var var WU4 = 2; while (true) { }; Var _ans158 = YAN3 [WU4 - 1]; var SU4YE2 = _ans158; if (SU4YE2) {ZHU1SU4.push (WU4);}; var _ans159 = 1 + WU4; WU4 = _ans159;}; return ZHU1SU4}; var _ans160 = AI1SHI4SHAI1 (100); console.log (_ans160);

Classical programming can not only output simple results, but also text maps (ASCII Art) can be drawn in classical Chinese. The famous "Mandberg collection" in fractal problems is drawn in Chinese like this:

Mandebo collection drawn in Chinese

Do you think this is the final form of the compilation result? Wrong Wrong!

The project file also has a script src / render.js, which can render the program like an ancient book. It's really exciting to print O’Reilly series books into ancient bound books.

Installation and use

The classical Chinese programming only needs to download the repo locally, and Node has been installed locally, and it can be used immediately. Now it supports converting wenyan lang to JavaScript and Pyth