Vecscript defines arithmetic, relational, logical, shift, set, assignment, list, string, object, caste, instance, allocation, and selection operators. The following table summarizes these operators.
|
Operator Type |
Operator |
Description |
Example |
|
Arithmetic |
+ |
Addition |
(+ a b c) |
|
|
- |
Subtraction |
(- a b) |
|
|
* |
Multiplication |
(* a b c) |
|
|
/ |
Division |
(/ a b) |
|
|
% |
Modulus |
(% a b) |
|
Relational |
> |
Greater than |
(> a b) |
|
|
< |
Less than |
(< a b) |
|
|
>= |
Greater than or equal |
(>= a b) |
|
|
<= |
Less than or equal |
(<= a b) |
|
|
<> |
Not equal |
(<> a b) |
|
|
== |
Equal |
(== a b) |
|
Logical |
not |
Not |
(not a) |
|
|
and |
AND |
(and a b c) |
|
|
or |
OR |
(or a b c) |
|
|
xor |
Exclusive or |
(xor a b) |
|
Shift |
<< |
Left-shift |
(<< a b) |
|
|
>> |
Right-shift |
(>> a b) |
|
|
>>> |
Zero-filled right-shift |
(>>> a b) |
|
Set |
+ |
Set union |
(+ a b c) |
|
|
- |
Set difference |
(- a b) |
|
|
* |
Set intersection |
(* a b c) |
|
|
== |
Set equality |
(== a b) |
|
|
<> |
Set inequality |
(<> a b) |
|
|
<= |
Set inclusion |
(<= a b) |
|
|
in |
Set membership |
(in a b) |
|
|
.. |
Subrange |
(.. a b) |
|
Assignment |
= |
Assignment |
= a b |
|
|
++ |
Increment and assign |
++ a |
|
|
-- |
Decrement and assign |
-- a |
|
|
=+ |
Add and assign |
+= a b |
|
|
=- |
Subtract and assign |
-= a b |
|
|
=* |
Multiply and assign |
*= a b |
|
|
=/ |
Divide and assign |
/= a b |
|
|
=% |
Take modulus and assign |
%= a b |
|
|
=| |
OR and assign |
|= a b |
|
|
=& |
AND and assign |
&= a b |
|
|
=^ |
XOR and assign |
^= a b |
|
|
=<< |
Left-shift and assign |
<<= a b |
|
|
=>> |
Right-shift and assign |
>>= a b |
|
|
=>>> |
Zero-filled right-shift and assign |
>>>= a b |
|
List |
pchild |
Get child pointer |
(pchild a) |
|
|
pnext |
Get next pointer |
(pnext a) |
|
|
pchild |
Set child pointer |
pchild a b |
|
|
pnext |
Set next pointer |
pnext a b |
|
|
atomic |
Is an atom? |
(atomic a) |
|
|
: |
List member |
(: a n) |
|
String |
+ |
Concatenation |
(+ a b c) |
|
Object |
: |
Property/Method |
(: a b c) |
|
Cast |
Type |
Convert to type |
(char a) |
|
Instance |
instanceof |
Is instance of class? |
(instanceof a b) |
|
Allocation |
new |
Create a new object of a class |
(new a) |
|
|
resize |
Change array size |
resize a m n |
|
Selection |
quest |
If…then selection |
(quest a b c) |