Operators & Symbols
This page features all the operators and symbols of Pa along with examples & snippets.
Basic Airthmetic
Normie arithmetic, used everywhere. Operand types must be numbers, except the + operator can be used for string concatenation as well.
//magik :)
1 + 2;
1430 - 320;
3 * 6;
9 / 2;
Bitwise Operations
Slightly advanced arithmetic, used for bit manipulation.
//what is this
25 | 5;
20 & 4;
600 >> 8;
210 << 1;
80 ^ 5;
Comparison & Equality
Unlike arithmetic operators who only work with number operands (except +). Comparison works for all types however there is no implicit conversion.
1 == 0;
540 != 540;
32 < 33;
1320 > 0xff;
1 <= 0;
1 >= 0.13;
1 == "1"; //always false.
Logicals
The and, the or and the !. Works on any type.
!true //false
true and true; // true
true and false; // false
true or true //true
true or false //true
false or false //false
Grouping
You can 'group' expressions using ( closed by ) after the expression. They are also used for calling if they are after an indentifier.
(1 + 2) * 2; // 6
1 + 2 * 2; // 5
( 1 + 2 * 2; //error.
Subscript
Subscripting can be done using the [ closed by ] after a list value.
list[1];
list[1 + 2];
list[]; //error
list[; //error
Blocks
Blocks can be created using the { closed by }.
{
let local = "wow!";
}
if 0 {
print("i will get executed!");
}