Rand Stats

ClassicalChinese

zef:slavenskoj

文言 - Classical Chinese Language Module for Raku

簡潔之美 / The Beauty of Conciseness
文言以簡馭繁,一字千金。程式之道亦然:簡潔、精確、優雅。古典漢語之凝練特質,恰與編程語言之設計哲學相合,使代碼如詩賦般雅致而有力。
Classical Chinese achieves complexity through simplicity, where each character carries profound meaning. This mirrors the essence of programming: concise, precise, and elegant. The condensed nature of Classical Chinese perfectly aligns with programming language design philosophy, making code as refined and powerful as classical poetry.

文言者,Raku程式語言之古典漢語模組也。以傳統漢字書寫程式,承古典文學之雅韻,融現代編程之精髓。

This module provides Classical Chinese (文言) language support for Raku, allowing you to write Raku programs using Classical Chinese characters, functions, and operators. It enables literary programming in the traditional written language of ancient China.

緣起 / Motivation

程式之道,源遠流長。今以文言為程式語言,蓋欲:

The art of programming has deep roots. By using Classical Chinese for programming, we aim to:

安裝法 / Installation

zef install 文言

或從源碼安裝 / Or from source:

zef install .

基本用法 / Basic Usage

use 文言;

# 示文輸出("天地玄黃,宇宙洪荒");

# 變數與問答
my $姓名 =("子何名焉?");("善哉,$姓名!");

# 數術運算
my @數列 =..;("其和為:", 求和(@數列));("其均為:", 平均(@數列));

# 文言運算符
my $結果 = 五 加 三 乘 二;("五加三乘二,得", $結果);

功能特色 / Features

基本輸入輸出 / Basic I/O

常數 / Constants

數學函數 / Mathematical Functions

文字處理 / String Functions

陣列處理 / Array Functions

文言運算符 / Classical Operators

算術 / Arithmetic

比較 / Comparison

邏輯 / Logical

範例集 / Examples

詩詞韻律分析 / Poetry Analysis

use 文言;

my $詩句 = "床前明月光,疑是地上霜";
my @= 字符列表($詩句);("詩句:$詩句");("字數:", 計數(@));("含'月'字:",($詩句, "") ?? "" !! "");

算學示例 / Mathematical Example

use 文言;

# 求一至百之和
my $= 求和(..);("一至百之和:", $);

# 驗證勾股定理
my $=;
my $=;
my $= 開方($甲 冪 二 加 $乙 冪 二);("勾三股四,弦", $);

文本處理 / Text Processing

use 文言;

my $文章 = "道可道,非常道。名可名,非常名。";
my @= 分割($文章, "");("文章:", $文章);("句數:", 計數(@));
遍歷(@, {(
        { 長度($_) > 0 },
        {("  句:", $_) }
    );
});

示例程式 / Example Programs

本模組含豐富示例,分為四類:

教育範例 / Educational Examples

實用範例 / Practical Examples

高級範例 / Advanced Examples

文化範例 / Cultural Examples

限制 / Limitations

因 Raku 現有限制(issue #2404),本模組未能改變核心語法結構。然所有函數與運算符皆可正常使用,足以文言撰寫完整程式。

Due to current Raku limitations (issue #2404), this module cannot modify core syntax structures. However, all functions and operators work correctly, enabling complete programs in Classical Chinese.

文化意義 / Cultural Significance

以文言編程,非僅技術之事,亦文化傳承之道也。程式碼如詩詞,邏輯如哲理,使編程成為一種文學藝術。

Programming in Classical Chinese is not merely a technical exercise but a means of cultural preservation. Code becomes poetry, logic becomes philosophy, transforming programming into a literary art.

貢獻 / Contributing

https://github.com/raku-multilingual/raku-classical-chinese

授權 / License

Artistic License 2.0

作者 / Author

Danslav Slavenskoj