𮅟號语𢍬
- The title of this article is also called 符号语言.
𮅟號语𢍬 is an esoteric programming language designed by PSTF, in order to avoiding any emoji-using, and trying to inherit the spirit of APL.
The name of this language '𮅟號语𢍬' should actually be '符号语言'(stands for Symbolic Language), because I deliberately looked up variant characters on https://zi.tools/.
It can be used as Xonovile 3.0 version.
Syntax and Semantics
Each command in 𮅟號语𢍬 is separated by a semicolon or a newline. We do not recommend using semicolons; instead, use newlines and indentation.
This is a short example:
甲 ← ⌨ 乙 ← ⌨ ⎕ ← (甲 + 乙)
Command List
Data
There are 8 data types:
- Numbers(③). Both integers and real numbers are considered as numbers.
- Documents(㉆). Quoted in 『』. 『『』』 for one that needn't any escape.
- Pair(◐). Just simply an ordered pair.
- After version 4.0, complex numbers(☯) exist independently as a type, represented in the form a + bi. The operations on number pairs mentioned below can only be applied to complex numbers.
- List(□). Acts like what in Python.
- Bool(◇). Either 真 or 假.
- Lambda(Λ). In fact it is just a function.
- Type(〓). Type itself is also type.
- Port (⎔). Specifies from where to output or from where to input.
Besides, we use ⍬ as NULL value. That's what APL used.
We also use the Dharma Wheel (☸) to represent any type, or an automatic type. A very strange fact is that I am not a Buddhist, but I used a Buddhist symbol.
Comment
※ Anything after the star sign in the line will be ignored. ※《Anything inside the block will be ignored.》※
I/O
YYY ← XXX XXX ← YYY
Here, it is assumed that XXX is the content to be input or output, and YYY is the place where the input information is stored or the output information is written. ⎕ means screen, which is STDOUT. ⌨ means computer, which is STDIN. You can also replace ⌨ with ⍄'XXX.input' to indicate that the data should be read from here. Or replace ⎕ with ⍃'XXX.output' to indicate that the data will be written here. Of course, the input and output files do not have to be in input and output formats; in and out, or even txt, can also be used as input and output files.
Assignment
Actually, the process of input and output is the same as the process of assignment, except that the input or output end is replaced with a variable.
(type) variable_name ← value
If you leave the value blank, it means assigning the default value to variable_name (for numbers, it is 0; for documents, it is an empty string; for pairs, it is (0, 0); for lists, it is an empty list; for functions, it is a function that does nothing). If you change the value to 'delete,' it means completely deleting variable_name, and to use this variable afterward, it must be redefined. You must specify a type when defining it, otherwise the compiler will automatically guess the type — a variable can only have one type!
Delaying and Halting
待 x 중단
These two commands, one waits for x milliseconds, and the other immediately stops the program. The program will automatically stop when it reaches the end.
待 ⌨
This command will require the user to press any key before proceeding to execute the following commands. During the wait, the screen will display the message Press any key to continue....
Arithmetic
A plus sign means addition, append or concatenate.
- For x + y,
- If both x and y are numbers, they're added together.
- If x is list and y is another element(must be string literal if x is string literal), it means to concatenate y to the tail of x.
- If both x and y are ordered pairs, let x = (a1, b1) and y = (a2, b2), then x + y = (a1 + a2, b1 + b2). Also suitable for if both x and y are complex numbers(Real numbers can be treated as complex numbers that has an imaginary part of 0. Complex numbers are formed by a + bi, where 1i is not equal to i).
A subtraction dash means subtraction. It only exist when both x and y are numbers, ordered pairs, or complex numbers.
A "×" means multiplication.
- For x × y,
- If both x and y are numbers, the result is multiply x by y.
- If x is list/string literal and y is number, x is repeated for y times.
- If both x and y are ordered pairs, let x = (a, b) and y = (c, d), then x × y = (ac - bd, bc - ad). Also suitable for if both x and y are complex numbers.
A "÷" means float division. Only exist when both x and y are numbers, ordered pairs, or complex numbers. If x = (a, b) and y = (c, d) then x ÷ y = ((ac + bd) ÷ (c² + d²), (bc - ad) ÷ (c² + d²)) where (c, d) ≠ (0, 0).
A slash means truncated division. It first get the result of x ÷ y, then round it towards 0. Use backslash for modulo.
An ASCII-circumflex means exponent.
- For x ^ y,
- If y can be represented by a ÷ b,
- If b is even, then for x which is below 0, return √|x| · i.
- If y is 0, then ignore x and return 1.
- If x is complex number that can be represented by a + bi, let r = a² + b², and convert x into r(cos(θ) + i sin(θ)) where θ = tan-1(b ÷ a), return rn(cos(nθ) + i sin(nθ)).
- If y can be represented by a ÷ b,
y√x is the shorthand of x^(1 ÷ y). If y = 0 then return NaN, represented by ⍬.
log_y(x) returns k if yk = x.
A list is represented by elements wrapped in bracket and seperated by comma.
⌈x⌉ is round x away from 0 and ⌊x⌋ is round x towards 0. _[[x]]_ is round as usual. .|x|. is absolute value.
Conditional Statements, Looping Statements, and Other Control Flows
If-Elif-Else
b?a:c
If b is true, return a; otherwise, return c. In the case where both a and c are functions, if b is true, execute a; otherwise, execute c.
While-Do
b?a⏎
a must be a function. Repeat executing a until b is not true.
Do-While
a⏎b?
a must be a function. Repeat executing a until b is not true. However, this structure will first execute a and then evaluate b.
Repeat-Until
a⏎b¿
a must be a function. Repeat executing a until b is true. This structure will first execute a and then evaluate b.
For-Do
对于i∈x b?|a⏎
For each i in x, if i satisfies condition b, then perform a on i. Leaving b blank means b is always true.
List Operations
⍰list_name means to grab a random thing from list_name.
区abcd represents generating a range with starting element a, ending element b, and step c, where d indicates whether it is an open interval, half-open interval, or closed interval. If there is only one parameter, it will be treated as b. If there are two, they will be a and b. If there are three, they are a, b, and c. The step defaults to 1. The starting element defaults to 0. The mode defaults to 3, which means it includes both the starting and ending elements.
∪ represents joining two lists together and removing duplicate elements (keeping only one) to form a new list, while ∩ represents forming a list of elements that are common to both lists.
∅ is an empty list.
a∈A returns if x is the lement of 𝔸, and A⊂B returns if 𝔸 is a subset to 𝔹.
ℂ, ℕ, ℚ, ℝ, and ℤ are reserved for Complex numbers, Natural numbers, Rational numbers, Real numbers, and Integers.==
Comparison, Bitwise Operations and Logical Operations
From left to right, ∧∨¬⊻ means AND, OR, NOT and XOR.
All of them can be used as logical or bitwise. When used as bitwise, it must be written in &&, ||, ~, and ^^.
= is equal, ≠ is not equal, < is below, ≤ is not above, > is above, ≥ is not below.
⍇ is left-shift. ⍈ is right-shift.
Definition of Functions
When defining functions, we must use the keyword λ to indicate that the functions in this language are based on λ abstraction. Then, you write a list with all the parameters. The list can be empty. If you assign a value to a parameter in advance, it means that if you leave the parameter blank, it will default to why. Then there is a code block. If you want to return a specific value, you can use the right arrow (→) and write down the value you want to return.
A function can be accessed anonymously. Enclose the definition of the function in parentheses, followed by a pair of square brackets containing all the actual parameters. You can also assign a function to a variable so that you can replace the definition of this function with the function name.
Object-Oriented Concepts
Of course, you can also create a class as a new data type. Therefore, in theory, 𮅟號语𢍬 has an infinite number of data types, and each data type is a subset of ☸, while these data types are all supersets of ⍬.
▣class_name {
※ attributes
※ methods
λ __init__ [⚛] {※《Initialization code here》※}
}
When initializing a variable of a custom data type, you must use an array to assign a specific actual value to each attribute.
On Variable Name
Any identifier that is legal in CangjieLang is also legal in 𮅟號语𢍬. At the same time, they cannot overlap with existing commands. However, you can enclose an identifier with〔〕on both sides to indicate a raw identifier. Any raw identifier that is legal in CangjieLang is also legal in 𮅟號语𢍬.
Examples
A+B Problem
甲 ← ⌨ ※ The meaning here is to read data from the port and infer its type from it. 乙 ← ⌨ ⎕ ← (甲 + 乙)
Hello, World!
I do not mean to spread any political ideas. I also do not hold any political ideas.
⎕ ← 『『 Stand up, all victims of supression, For the tyrants fear your might! Don't cling so hard to your possession, For you have nothing if you have no rights! Let racist ignorance be ended, For respects makes the empire fall. Freedom is merely privileges extended, Unless enjoyed by one and ALL. So come brothers and sisters, For the struggle carries on. The Internationale, Unites the world in song! So comrades, come rally, For this is the time and place! The International Ideal, Unites the human race! Let no one build walls to divide us, Walls of hatred nor walls of stone. Come greet the dawn and stand beside us, We'll live together or we'll die alone. In our world poisoned by exploitation, Those who have taken, now they must GIVE! And end the vanity of nations, We've but one Earth on which to live. So come brothers and sisters, For the struggle carries on. The Internationale, Unites the world in song! So comrades, come rally, For this is the time and place! The International Ideal, Unites the human race! And so begins the final drama, In the streets and in the fields. We stand unbowed before their armour, We defy their guns and shields! When we fight, provoked by their aggresion, Let us be inspired by life and love. For though they offer us concessions, Change will not come from above! So come brothers and sisters, For the struggle carries on. The Internationale, Unites the world in song! So comrades, come rally, For this is the time and place! The International Ideal, Unites the human race! 』』
More Examples
Coming soon. Allows adding example programs by yourself.