CJKGolfer is designed by PSTF, which is inspired from Sclipting.
Most basic syntax
Execution
CJKGolfer has a stack, and infinity amount of variables.
Many of the instructions are based on stack.
Data types
- Numbers(数). Every real numbers are allowed to 数, such as 二根三加五七分六减四点三七八.
- Complex(复). Write as 数实数虚. They converts to its geometrical absolute value when converts to integer.
- Strings(字). Quote by 『』. \『 is 『 , \』 is 』, \\ is \, \控x is U+x.
- Boolean(逻). 真 or 假.
- Array(列). Quote by 【】, and seperate by ,.
- Nil(空). Only 空.
- Undefined behaviour. Something that weird, such as 五除〇.
- Lambda(函). Simply a function.
|
Number
|
Complex
|
Boolean
|
String
|
Array
|
Nil
|
Undefined
|
Number
|
|
|x|
|
x ? 1 : 0
|
parseInt(x) or 0
|
length(x)
|
0
|
0
|
Complex
|
x+0i
|
|
x ? 1.0 : 0.0
|
parseFloat(x) or 0.0
|
length(x) / 1
|
0.0
|
0.0
|
Boolean
|
x != 0
|
x != 0+0i
|
|
x != ""
|
x != []
|
true
|
false
|
String
|
toString(x)
|
toString(x)
|
x ? "true" : "false"
|
|
"[" + ", ".join(x) + "]"
|
""
|
99 bottles of beer
|
Array
|
[x]
|
[x]
|
[x]
|
[x]
|
|
[]
|
[Undefined]
|
Both base 10 and base 100 are accepted. Base 100 is quoted in 百……百.
〇一二三四五六七八九
甲乙丙丁戊己庚辛壬癸
子丑寅卯辰巳午未申酉
戌亥零壹贰叁肆伍陆柒
捌玖乾兑离震巽坎艮坤
氢氦锂铍硼碳氮氧氟氖
钠镁铝硅磷硫氯氩钾钙
钪钛钒铬锰铁钴镍铜锌
镓锗砷硒溴氪铷锶钇锆
铌钼锝钌铑钯银镉铟锡
instruction
There are currently two type of instruction.
- Non-argumented individual instructions. Many statements fall into this category, they are not passed arguments, and they just do a separate thing.
- Argumented individual instructions. Same as above, but argumented.
- Block of code. They're stopped by 止(zhi3) and started by 作(zuo4).
Program will directly run, and throw SyntaxError when not matched code block. Comments are quoted in 「」.
Stack manipulations
Discard
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
拉 |
la1 |
Pull |
This is Argumented individual instruction. It receives x, and pop top x-th item from the stack and return it(1-based). Leave blank means top.
|
丢 |
diu1 |
Throw |
This is Non-argumented individual instruction. It pop top item from the stack and return it.
|
弃 |
qi4 |
Abandon |
This is Argumented individual instruction. It receives x, and pop top x items from the stack and return them as array. Leave blank means 1.
|
毁 |
hui3 |
Destroy |
This is Non-argumented individual instruction. It pop top item from the stack and discard it.
|
灭 |
mie4 |
Destroy |
This is Argumented individual instruction. It receives x, and pop x-th item from the stack and discard them. Leave blank means top.
|
求 |
qiu2 |
Beg |
This is Argumented individual instruction. It receives x, and return top x-th item from the stack but not pop it. Leave blank means top.
|
Push
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
推 |
tui1 |
Push |
This is Argumented individual instruction. It receives x, and push x into stack.
|
扔 |
reng1 |
Throw |
This is Non-argumented individual instruction. It duplicates stack top.
|
跨 |
kua4 |
Across over |
This is Argumented individual instruction. It receives x, and push a copy top x-th item of stack. Leave blank means 1.
|
Control flow
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
若 x 则 ... 否 ... 止 |
ruo4 ze2 fou3 zhi3 |
If x then ... else ... endif |
This is statement block. If x returns true, then do code 1, else code 2. You can construct elif by 否若.
|
循 ... 止 |
xun2 zhi3 |
Loop ... endloop |
This is statement block. It is an infinity loop.
|
若 x 作 ... 止 |
ruo4 zuo4 zhi3 |
If x then do ... endloop |
This is statement block. It is a conditional loop.
|
对 i 之 r 作 ... 止 |
dui4 zhi1 zuo4 zhi3 |
For r in i do ... endloop |
This is statement block. It is an iterative loop.
|
退 |
tui4 |
Exit |
This is Non-argumented individual instruction. It exit the current loop. 退!退!退! will exit current program.
|
过 |
guo4 |
Pass |
This is Non-argumented individual instruction. It jumps to next round of the loop.
|
虚 |
xu1 |
Void |
This is Non-argumented individual instruction. It does nothing.
|
屌 |
diao3 |
D*ck |
This is Non-argumented individual instruction. It quits the programming environment.
|
Calculation
Two argumented infix
Syntax: x⊙y
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
加 |
jia1 |
Addition |
This is Argumented individual instruction. Return x + y.
|
减 |
jian3 |
Subtraction |
This is Argumented individual instruction. Return x - y.
|
扣 |
kou4 |
Reduce |
This is Argumented individual instruction. Return y - x.
|
乘 |
cheng2 |
Multiplication |
This is Argumented individual instruction. Return x × y.
|
除 |
chu2 |
Division |
This is Argumented individual instruction. Return x ÷ y. Result in Float.
|
掰 |
bai1 |
Break |
This is Argumented individual instruction. Return x ÷ y. Result in Integer(quotient of it).
|
分 |
fen1 |
Divide |
This is Argumented individual instruction. Return x/y. It is simply a fraction.
|
剩 |
sheng4 |
Remain |
This is Argumented individual instruction. Return x mod y. Result in Positive Integer, even if x is negative, just like Python(-1 % 3 = 2).
|
幂 |
mi4 |
Power |
This is Argumented individual instruction. Return xy.
|
根 |
gen1 |
Root |
This is Argumented individual instruction. Return x1/y. Leave y blank means y = 2.
|
子 |
zi3/zi0 |
Numerator |
This is Argumented individual instruction. Return numerator of x/y.
|
母 |
mu3 |
Denominator |
This is Argumented individual instruction. Return denominator of x/y.
|
双 |
shuang1 |
Double |
This is Argumented individual instruction. Return x AND y.
|
另 |
ling4 |
Other |
This is Argumented individual instruction. Return x OR y.
|
俩 |
lia3 |
Two |
This is Argumented individual instruction. Return x XOR y.
|
Two argumented prefix
Syntax: ⊙x,y
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
对 |
dui4 |
Logarithm |
This is Argumented individual instruction. Return logyx. Leave y blank means y = e.
|
癫 |
dian1 |
Mad |
This is Argumented individual instruction. Return a random integer between x and y.
|
疯 |
feng1 |
Crazy |
This is Argumented individual instruction. Return a random float between x and y.
|
One argumented prefix
Syntax: ⊙x
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
圈 |
quan1 |
Circle |
This is Argumented individual instruction. Round x towards zero.
|
圆 |
yuan2 |
Circle |
This is Argumented individual instruction. Round x away from zero.
|
围 |
wei2 |
Around |
This is Argumented individual instruction. Round x towards +∞.
|
圜 |
huan2/yuan2 |
Circular |
This is Argumented individual instruction. Round x towards -∞.
|
绕 |
rao4 |
Surround |
This is Argumented individual instruction. Round x as usual(If the decimal part is less than 0.5, the decimal part is discarded. If the decimal part is greater than or equal to 0.5, add 1 to the integer part after discarding the decimal part).
|
整 |
zheng3 |
Integer |
This is Argumented individual instruction. Round x to the nearest integer (halves are rounded to even).
|
痫 |
xian2 |
Epilepsy |
This is Argumented individual instruction. Return a random integer between 0 and x.
|
病 |
bing4 |
Sick |
This is Argumented individual instruction. Return a random float between 0 and x.
|
绝 |
jue2 |
Absolute |
This is Argumented individual instruction. Return |x|. If x is complex, return its geometrical absolute value.
|
没 |
mei2 |
No |
This is Argumented individual instruction. Return NOT x.
|
Non-argumented
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
混 |
hun4 |
Chaos |
This is Argumented individual instruction. Return a random integer between 0 and 127.
|
沌 |
dun4 |
Chaos |
This is Argumented individual instruction. Return a random integer between 0 and 2147483647.
|
野 |
ye3 |
Wild |
This is Argumented individual instruction. Return a random integer between 0 and 9223372036854775807.
|
蛮 |
man2 |
Savage |
This is Argumented individual instruction. Return a random float between 0 and 1.
|
Logical
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
多 |
duo1 |
More |
This is Argumented individual instruction. Return true if x>y, else false.
|
少 |
shao3 |
Less |
This is Argumented individual instruction. Return true if x<y, else false.
|
沉 |
chen2 |
Sink |
This is Argumented individual instruction. Return true if x≥y, else false.
|
浮 |
fu2 |
Float |
This is Argumented individual instruction. Return true if x≤y, else false.
|
同 |
tong3 |
Same |
This is Argumented individual instruction. Return true if x=y, else false.
|
异 |
yi4 |
Different |
This is Argumented individual instruction. Return true if x≠y, else false.
|
与 |
yu3 |
And |
This is Argumented individual instruction. Return true if both x and y return true.
|
或 |
huo4 |
Or |
This is Argumented individual instruction. Return true if either x or y return true.
|
又 |
you4 |
One in pair |
This is Argumented individual instruction. Return true if one in x and y(but not both) return true.
|
不 |
bu4 |
No |
This is Argumented individual instruction. Return true if x return false.
|
I/O
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
出 |
chu1 |
Out |
This is Argumented individual instruction. Print the value of x.
|
入 |
ru4 |
In |
This is Argumented individual instruction. Input a string with specified prompt and return it.
|
写 |
xie3 |
Write |
This is Argumented individual instruction. Print a serie of value, with specified seperator(割) and terminator(终).
|
读 |
du2 |
Read |
This is Argumented individual instruction. Input an expression with specified prompt and evaluate its result, and return it.
|
Variable
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
置 |
zhi4 |
Set |
This is Argumented individual instruction. It receive a name, a type, and a value. Name can be any other Chinese Characters, Kanas, and Hangul Syllables. Define a variable with specified name, type, and value. Name must not exist. This is inspired by SLet.
|
让 |
rang4 |
Let |
This is Argumented individual instruction. It receive a name, and a value. Assign the new value to the variable. Assign with type will change its type. This is inspired by SLet.
|
List operations
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
理 |
li3 |
Tidy up |
This is Argumented individual instruction. Sort a list immediately. Strings are sorted by dictionary order, array also do that, false < true, complex are sorted by their absolute value. Such as, 3+4i > 1+1i(because 5 > sqrt(2)). Empty < Bool < Number < Complex < String < List.
|
搅 |
jiao3 |
Stir |
This is Argumented individual instruction. Suffle a list randomly.
|
拌 |
ban4 |
Mix |
This is Argumented individual instruction. Generate a shuffled list.
|
切 |
qie1 |
Slice |
This is Argumented individual instruction. It receive a list and two integers(x and y), and return the slice from x to y of the list(0-based indexing).
|
接 |
jie1 |
Join |
This is Argumented individual instruction. It receive two list, and join second in the tail of first, then return it.
|
囸 |
ri4 |
F**k |
This is Argumented individual instruction. Join two list, and shuffle the result.
|
讨 |
tao3 |
Beg |
This is Argumented individual instruction. It receive a list and an integer(x), and return the x-th item of the list(0-based indexing).
|
插 |
cha1 |
Insert |
This is Argumented individual instruction. Insert the specified element in the x-th place of the list. Leave x(integer) blank means insert at tail.
|
嘣 |
beng1/beng0 |
Boom! |
This is Argumented individual instruction. Pop the element in the x-th place of the list, and return it. Leave x blank means tail.
|
嘭 |
peng1/peng0 |
Boom! |
This is Argumented individual instruction. Pop the element in the x-th place of the list, but not return it. Leave x blank means tail.
|
Function
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
函 |
han2 |
Function |
This is Head of code block. It starts a lambda function. You can allocate a lambda function to a variable. Syntax: 函arg_list作code止.
|
呼 |
hu1 |
Call |
This is Argumented individual instruction. Calls the function with specified name(anonymous is 功), and with specified argument list.
|
Class
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
类Name性Attr置初函我作Initialization止置名函args作methods止止 |
let4 xing4 zhi4 chu1 han2 wo3 zuo4 zhi3 zhi4 ming2 han2 zuo4 zhi3 zhi3 |
Class, attributes, initializations, methods |
This is Full code block. Define a class.
|
→ |
? |
? |
This is Operator. Points to the method or attribute of a class.
|
Import
Command Table
Command |
Pronounciation |
Corresponding English |
Meaning
|
引 |
yin3 |
Import |
This is Argumented individual instruction. Imports a library. Library can be used as class.
|
Example
Add by yourself. I was constructed this for three nights, I have no effort on the example.
Categories, Notes, and References