Operators
Every Operator
There are many operators in ArrEx. Here is a table of them.
Name | Symbol | Use | Code | Comments |
---|---|---|---|---|
Plus | + | Adding numbers, strings, or arrays | 1 + 2 | 3 |
Minus | - | Subtracting numbers | 2 - 1 | 1, can be used for negation as in -3 |
Multiplication | * | Multiplying numbers | 2 * 3 | 6 |
Division | / | Dividing numbers | 5 / 4 | 1.25 |
Parenthesis | () | Prioritize code or denotes function code | 3 / (1 + 4) | 0.6 |
Curly Brackets | {} | Prioritize code and make function parameters more readable | 3 / {1 + 4} | 0.6 |
Exponent | ^ | Exponentiation | 2 ^ 3 | 8 |
Modulus | % | Getting the remainder | 15 % 2 | 1 |
Int Division | // | Gets the int part in division | 5 // 2 | 2, useful for making numbers integers |
Equal | == | Checking equality between values | 5 == 2 | False |
Not Equal | != | Checking inequality between values | 5 != 2 | True |
Greater than | > | Checking if a number is bigger than another | 5 > 2 | True |
Less than | < | Checking if a number is smaller than another | 5 < 2 | False |
Greater than or equal | >= | Checking if a number is bigger than or equal to another | 3 >= 3 | True |
Less than or equal | <= | Checking if a number is smaller than or equal to another | 3 <= 3 | True |
Boolean Not | ! | Negates a boolean | !T | False |
Comma | , | Separates certain code in some functions | ar(1, 2, 3, 4 ) | [1, 2, 3 ,4], ar makes an array |
Type equal | ~= | Checks if a value is a type | 3 ~= tn | True, tn means number type |
In | _ | Checks if a value is in an array | 3_ar(1, 2, 3, 4) | True |
Count | # | Checks how many times a value occurs in an array | 3#ar(1, 2, 3, 4, 3, 5) | 2 |
At | @ | Checks where a value is in an array | 3@ar(1, 2, 3, 4) | 2 |
Skim | >> | Removes all instances of a value in an array | ar(1, 2, 3, 4) >> 2 | [1, 3, 4] |
Conditional If | ? : | Does something different depending on if something is true or not | 3 == 3 ? 50 : 20 | 50 |
Order of Operations
There is an order of operations that the operators work in.
Precedence | Operators |
---|---|
1 | ? :, (), {} |
2 | _, #, @, >> |
3 | ^ |
4 | *, /, %, // |
5 | + - (includes negation) |
6 | ! |
7 | ~=, >, <, >=, <=, ==, != |
8 | &, | |