+-*/// (divide then round
down)%%%. Returns true if the right operand
evenly divides the left operand. (That is, a %% b is the
same as a % b = 0)^, e.g. a^3 raises
a to the 3rd power.and, or,
xor, not. Note that the and and
or operators can short-circuit, i.e. given an expression
a and b: if a is false, then the whole
expression can never be true, so b is not even
evaluated.bitwise and,
bitwise or, bitwise xor,
bitwise not. Unlike the boolean operators, these do not
short-circuit.>, >=,
<, <==!=exists
(e.g. x exists):. Note that slices are inclusive of
both their upper and lower bounds (e.g. 0:5 gives
(0,1,2,3,4,5))
0:10:2
is read “0 to 10 step 2”, and gives (0,2,4,6,8,10)."abcdef"[4::] would result in "def",
(5,4,3,2,1)[2::] would result in (4,3,2,1),
etc., (e.g. 1,2,3 is an array
with 3 elements, (1,) is an array with 1 element,
(,) has 0 elements, etc). You can combine this with
slicing, e.g. 1,3:5,9 gives (1,3,4,5,9).like, checks whether a string matches
a given pattern (e.g. "123" like "%d+" gives
true).in (e.g. 3 in (1,2,4,5,6)
gives false)&
(e.g. "abc" & "def" gives "abcdef")val1 if expression else val2. Like
Python’s ternary syntax, this will result in val1 if
expression evaluates to true, otherwise it will result in
val2.val1 else val2. Results in
val1 if val1 is truthy, otherwise results in
val2. Syntax sugar for
val1 if val1 else val2.val1 then val2. Results in
val2 if val1 is truthy, otherwise results in
val1. Syntax sugar for
val2 if val1 else val2.val1 ?else val2. Results in
val1 if val1 is not null, otherwise results in
val2. Syntax sugar for
val1 if val1 != null else val2.val1 ?then val2. Results in
val2 if val1 is not null, otherwise results in
val1. Syntax sugar for
val1 if val1 = null else val2.[]. Like most languages, this lets you get an
element from a string, array, or object (e.g. "string"[2]
gives “t”, ('a','b','c')[3] gives “c”, and
('a'=>'v1', 'b'=>'v2')['a'] gives “v1”), however
Paisley also lets you select multiple items at once in a single index
expression. E.g. "abcde"[2,5,5] gives “bee”,
"abcde"[1:3] gives “abc”, (6,7,8,9,0)[3,1,5]
gives (8,6,0)... This is purely syntax sugar. When used
with functions, the left side of the dot is treated as the first
argument to the function, e.g. val1.func(val2, ...) =
func(val1, val2, ...). When used with identifiers, a dot is
shorthand for object indexing, e.g. obj.attr =
obj["attr"].Operator precedence in Paisley follows the table below, from higher to lower priority:
. []
^
- not bitwise not (unary
operators)
:
* / // % %%
+ -
> < >= <= = != in like not in not like
&
exists and or xor
and any bitwise versions of the latter 4.
a for b in c a for b in c if d
a if b else c a else b a ?else b a then b a ?then b
=>
,