Wenyan, but now it looks like a book

From Esolang
Jump to navigation Jump to search
This is still a work in progress. It may be changed in the future.

Wenyan, but now it looks like a book is an esolang by User:Yoyolin0409. Its inspiration comes from Wenyan. I made some of the programs inside look like ancient Chinese books.

Instructions

Start

All instructions not preceding the start instruction will be ignored. Some of these start instructions have functionality, while others do not. The start instructions will only be detected once.

為詩曰:

If it appears in any line

一一一一一一一一一一

It also retains its original function.

Output

Poetry

Poetry is a special format that begins with a 題曰: to be output once and ends with a 落款: to be output once. Example:

題曰:
<text>
...
落款:
<text>

Poetry's Content

夫作詩之妙,
以<number>物合而為一,則意趣自生,妙不可言:
一者曰<type><value>
二者曰<type><value>
三者曰<type><value>
...
<number>者曰<type><value>

Connect all items together in the specified order, then output. In addition, the variable's type name is "" (yes, it has no name), the string's name is "".

Misc

曰:吾<list_name>之<var_name>。

Output one variable from the list

Assignment

是日也,凡<value>舉<var_name>。

<value> must be an integer

每飲<value>爵,

The value used by the "今" assignment method in the next line will be the number specified by the "今" assignment method minus <value>.

是日也,吾<var_name><value>尺。

<value> must be an float

是日也,<name>為一列。

Declare an empty list named <var_name>.

是日有<number>物焉,<var_name1>唯/凡<value1>,<var_name2>唯/凡<value2>,<var_name3>唯/凡<value3>...。

Define multiple variables. If <value> is one, use "唯"; otherwise, use "凡".

是日,<name>有一列。

Same as "是日也,<name>為一列。"

<list_name>所有者,先<value1>,又<value2>,又<value3>...,所在皆是。

Store the values ​​sequentially into the list.

吾<name>至一列

Same as "是日也,<name>為一列。"

<name>亦有一列。

Same as "是日也,<name>為一列。"

<list_name>之所載者,乃<var_name>也。

Store a single variable in a list.

吾<list_name>至<value>之處。

Store a single value in a list.

是日也,<var_name>有<value>焉。

Same as "是日也,凡<value>舉<var_name>。"

<list_name>之<var_name>,名曰<var_name>。

Set one of the variables as another variable. <list_name>有<var_name>。 Same as "<list_name>之所載者,乃<var_name>也。"

"今" assignment method

則前之<var_name>數,遂為今數矣。

Control Flow

<var_name>尚在時,恒復如是。

Repeat the "following line to the one control flow end instructions", until <var_name> is not zero.

以吾之<var_name>,逐尺而記,並以其數施法。

Repeat the "following line to the one control flow end instructions" <var_name> times

以<list_name>之長為<var_name>,並以其數施法。

Repeat the "following line to the one control flow end instructions" <list_name>'s length times, Define variables at the same time

<var_name>少一,名曰<var_name>,並以其數施法。

Repeat the "following line to the one control flow end instructions" <var_name>-1 times, Define variables at the same time

恒爾如是。

Repeat the "following line to the one control flow end instructions" Unlimited times.

殺無赦。

End the program

若<var_name>盡。

if <var_name>=0:

若不然。

else

以<var_name1>之<var_name2>施圓環之法。

for (var var_name2 of var_name1):

Control Flow End

詩至此而止。

or

如此而已。

Comment

一一一一一一一一一一
<text>
一一一一一一一一一一

<text> will be treated as a comment.

Math

<var_name1>復多一焉,名曰<var_name2>。

Increment the variable by one and store the result in another variable.

Function

吾有一術,名曰「<name>」。欲施此術,必先備<number>物:<var_name1>、<var_name2>、...與<var_namex>。

Declare a function named <name> and require <value> as input. And the code from the next line to the function end instructions is used as the function content.

乃得乙焉。

Returns <var_name>

施長「<name>」之術,以<var_name1>為<var_name1>,以<var_name2>為<var_name2>,...,乃得<var_name_for_return>。

Call function

Function End Instructions

是謂「<var_name>」之術也。

Example

綠酒千杯腸已爛

頃者春日之宴,甚佳,因強為詩曰:

題曰:
春日宴

是日也,凡九舉酒。
酒尚在時,恒復如是。

夫作詩之妙,
以三物合而為一,則意趣自生,妙不可言:
其一曰一詞「與君」,
其二曰酒之數,
其三曰一詞「杯酒。可以窮歡宴。綠酒一杯歌一遍」。

每飲一爵,
則前之酒數,遂為今數矣。

詩至此而止。

落款:
綠酒千杯腸已爛。

Breadth-first search

一一一一一一一一一一
廣度優先搜尋之法,乃一暴索之術也。其志在循序而展,遍驗圖中諸節,以求其得。不計其或然之處,盡歷全圖,得之乃止。是法不用權變之術。
一一一一一一一一一一
是日也,吾身長五尺。
一一一一一一一一一一
節之數。
一一一一一一一一一一
是日也,橋為一列。
一一一一一一一一一一
鄰接之簿。
一一一一一一一一一一
是日有二物焉,始處唯一,止處凡五。
一一一一一一一一一一
相鄰之節:一通於二,一通於三;二通於一,二通於四,二通於五;三通於一,三通於四;四通於二,四通於三,四通於五;五通於二,五通於四。
一一一一一一一一一一
是日,東方有一列。
東方所有者,先一,又一,又二,又二,又二,又三,又三,又四,又四,又四,又五,又五,所在皆是。
是日,南方有一列。
南方所有者,先二,又三,又一,又四,又五,又一,又四,又二,又三,又五,又二,又四,所在皆是。
吾步至一列。
以吾之長,逐尺而記,並以其數施法。
乙亦有一列。
橋之所載者,乃乙也。
吾步至千千之處。
如此而已。
是日也,甲有一焉。
以東方之長為丁,並以其數施法。
東方之甲,名曰東岸。
南方之甲,名曰南岸。
橋之東岸,名曰衍。
南岸有衍。
則前之橋東岸,遂為衍矣。
甲復多一焉,名曰丙。
則前之甲,遂為丙矣。
如此而已。
吾有一術,名曰「過河拆橋」。欲施此術,必先備二物:兵營與辛香料。
是日也,乙有一列。
是日也,甲有一焉。
辛香料少一,名曰壬,並以其數施法。
兵營之甲,名曰戊。
乙有戊。
甲復多一焉,名曰丙。
則前之甲,遂為丙矣。
如此而已。
乃得乙焉。
是謂「過河拆橋」之術也。
恒爾如是。
以兵營之長為辛香料,並以其數施法。
若辛香料盡。
殺無赦。
如此而已。
若不然。
兵營之辛香料,名曰前方。
施長「過河拆橋」之術,以兵營為兵營,以辛香料為辛香料,乃得乙。
則前之兵營,遂為乙矣。
吾之前之步,名曰上方。
上方復多一焉,名曰正方。
橋之前方,名曰癸。
以癸之丁施圓環之法。
吾之丁步,名曰下方。
若下方大於正方。
則前之吾步之丁,遂為正方矣。
兵營有丁。
若不然。
如此而已。
如此而已。
曰:吾步之終點。