Skip to main content
Last updated

Operators

!=

x <a[integer,string,time,decimal,bool,[<l>],object:<{o}>,keyset,guard,module{}]> y <a[integer,string,time,decimal,bool,[<l>],object:<{o}>,keyset,guard,module{}]>  bool

True if X does not equal Y.

bash
pact> (!= "hello" "goodbye")true
bash
pact> (!= "hello" "goodbye")true

&

x integer y integer  integer

Compute bitwise X and Y.

bash
pact> (& 2 3)2pact> (& 5 -7)1
bash
pact> (& 2 3)2pact> (& 5 -7)1

*

x <a[integer,decimal]> y <a[integer,decimal]>  <a[integer,decimal]>

x <a[integer,decimal]> y <b[integer,decimal]>  decimal

Multiply X by Y.

bash
pact> (* 0.5 10.0)5.0pact> (* 3 5)15
bash
pact> (* 0.5 10.0)5.0pact> (* 3 5)15

+

x <a[integer,decimal]> y <a[integer,decimal]>  <a[integer,decimal]>

x <a[integer,decimal]> y <b[integer,decimal]>  decimal

x <a[string,[<l>],object:<{o}>]> y <a[string,[<l>],object:<{o}>]>  <a[string,[<l>],object:<{o}>]>

Add numbers, concatenate strings/lists, or merge objects.

bash
pact> (+ 1 2)3pact> (+ 5.0 0.5)5.5pact> (+ "every" "body")"everybody"pact> (+ [1 2] [3 4])[1 2 3 4]pact> (+ { "foo": 100 } { "foo": 1, "bar": 2 }){"bar": 2,"foo": 100}
bash
pact> (+ 1 2)3pact> (+ 5.0 0.5)5.5pact> (+ "every" "body")"everybody"pact> (+ [1 2] [3 4])[1 2 3 4]pact> (+ { "foo": 100 } { "foo": 1, "bar": 2 }){"bar": 2,"foo": 100}

-

x <a[integer,decimal]> y <a[integer,decimal]>  <a[integer,decimal]>

x <a[integer,decimal]> y <b[integer,decimal]>  decimal

x <a[integer,decimal]>  <a[integer,decimal]>

Negate X, or subtract Y from X.

bash
pact> (- 1.0)-1.0pact> (- 3 2)1
bash
pact> (- 1.0)-1.0pact> (- 3 2)1

/

x <a[integer,decimal]> y <a[integer,decimal]>  <a[integer,decimal]>

x <a[integer,decimal]> y <b[integer,decimal]>  decimal

Divide X by Y.

bash
pact> (/ 10.0 2.0)5.0pact> (/ 8 3)2
bash
pact> (/ 10.0 2.0)5.0pact> (/ 8 3)2

<

x <a[integer,decimal,string,time]> y <a[integer,decimal,string,time]>  bool

True if X < Y.

bash
pact> (< 1 3)truepact> (< 5.24 2.52)falsepact> (< "abc" "def")true
bash
pact> (< 1 3)truepact> (< 5.24 2.52)falsepact> (< "abc" "def")true

<=

x <a[integer,decimal,string,time]> y <a[integer,decimal,string,time]>  bool

True if X <= Y.

bash
pact> (<= 1 3)truepact> (<= 5.24 2.52)falsepact> (<= "abc" "def")true
bash
pact> (<= 1 3)truepact> (<= 5.24 2.52)falsepact> (<= "abc" "def")true

=

x <a[integer,string,time,decimal,bool,[<l>],object:<{o}>,keyset,guard,module{}]> y <a[integer,string,time,decimal,bool,[<l>],object:<{o}>,keyset,guard,module{}]>  bool

Compare alike terms for equality, returning TRUE if X is equal to Y. Equality comparisons will fail immediately on type mismatch, or if types are not value types.

bash
pact> (= [1 2 3] [1 2 3])truepact> (= 'foo "foo")truepact> (= { 'a: 2 } { 'a: 2})true
bash
pact> (= [1 2 3] [1 2 3])truepact> (= 'foo "foo")truepact> (= { 'a: 2 } { 'a: 2})true

>

x <a[integer,decimal,string,time]> y <a[integer,decimal,string,time]>  bool

True if X > Y.

bash
pact> (> 1 3)falsepact> (> 5.24 2.52)truepact> (> "abc" "def")false
bash
pact> (> 1 3)falsepact> (> 5.24 2.52)truepact> (> "abc" "def")false

>=

x <a[integer,decimal,string,time]> y <a[integer,decimal,string,time]>  bool

True if X >= Y.

bash
pact> (>= 1 3)falsepact> (>= 5.24 2.52)truepact> (>= "abc" "def")false
bash
pact> (>= 1 3)falsepact> (>= 5.24 2.52)truepact> (>= "abc" "def")false

^

x <a[integer,decimal]> y <a[integer,decimal]>  <a[integer,decimal]>

x <a[integer,decimal]> y <b[integer,decimal]>  decimal

Raise X to Y power.

bash
pact> (^ 2 3)8
bash
pact> (^ 2 3)8

abs

x decimal  decimal

x integer  integer

Absolute value of X.

bash
pact> (abs (- 10 23))13
bash
pact> (abs (- 10 23))13

and

x bool y bool  bool

Boolean logic with short-circuit.

bash
pact> (and true false)false
bash
pact> (and true false)false

and?

a x:<r> -> bool b x:<r> -> bool value <r>  bool

Apply logical 'and' to the results of applying VALUE to A and B, with short-circuit.

bash
pact> (and? (> 20) (> 10) 15)false
bash
pact> (and? (> 20) (> 10) 15)false

ceiling

x decimal prec integer  decimal

x decimal  integer

Rounds up value of decimal X as integer, or to PREC precision as decimal.

bash
pact> (ceiling 3.5)4pact> (ceiling 100.15234 2)100.16
bash
pact> (ceiling 3.5)4pact> (ceiling 100.15234 2)100.16

dec

x integer  decimal

Cast an integer to a decimal value of integer X as decimal.

bash
pact> (dec 3)3.0
bash
pact> (dec 3)3.0

exp

x <a[integer,decimal]>  <a[integer,decimal]>

Exp of X.

bash
pact> (round (exp 3) 6)20.085537
bash
pact> (round (exp 3) 6)20.085537

floor

x decimal prec integer  decimal

x decimal  integer

Rounds down value of decimal X as integer, or to PREC precision as decimal.

bash
pact> (floor 3.5)3pact> (floor 100.15234 2)100.15
bash
pact> (floor 3.5)3pact> (floor 100.15234 2)100.15

ln

x <a[integer,decimal]>  <a[integer,decimal]>

Natural log of X.

bash
pact> (round (ln 60) 6)4.094345
bash
pact> (round (ln 60) 6)4.094345

log

x <a[integer,decimal]> y <a[integer,decimal]>  <a[integer,decimal]>

x <a[integer,decimal]> y <b[integer,decimal]>  decimal

Log of Y base X.

bash
pact> (log 2 256)8
bash
pact> (log 2 256)8

mod

x integer y integer  integer

X modulo Y.

bash
pact> (mod 13 8)5
bash
pact> (mod 13 8)5

not

x bool  bool

Boolean not.

bash
pact> (not (> 1 2))true
bash
pact> (not (> 1 2))true

not?

app x:<r> -> bool value <r>  bool

Apply logical 'not' to the results of applying VALUE to APP.

bash
pact> (not? (> 20) 15)false
bash
pact> (not? (> 20) 15)false

or

x bool y bool  bool

Boolean logic with short-circuit.

bash
pact> (or true false)true
bash
pact> (or true false)true

or?

a x:<r> -> bool b x:<r> -> bool value <r>  bool

Apply logical 'or' to the results of applying VALUE to A and B, with short-circuit.

bash
pact> (or? (> 20) (> 10) 15)true
bash
pact> (or? (> 20) (> 10) 15)true

round

x decimal prec integer  decimal

x decimal  integer

Performs Banker's rounding value of decimal X as integer, or to PREC precision as decimal.

bash
pact> (round 3.5)4pact> (round 100.15234 2)100.15
bash
pact> (round 3.5)4pact> (round 100.15234 2)100.15

shift

x integer y integer  integer

Shift X Y bits left if Y is positive, or right by -Y bits otherwise. Right shifts perform sign extension on signed number types; i.e. they fill the top bits with 1 if the x is negative and with 0 otherwise.

bash
pact> (shift 255 8)65280pact> (shift 255 -1)127pact> (shift -255 8)-65280pact> (shift -255 -1)-128
bash
pact> (shift 255 8)65280pact> (shift 255 -1)127pact> (shift -255 8)-65280pact> (shift -255 -1)-128

sqrt

x <a[integer,decimal]>  <a[integer,decimal]>

Square root of X.

bash
pact> (sqrt 25)5.0
bash
pact> (sqrt 25)5.0

xor

x integer y integer  integer

Compute bitwise X xor Y.

bash
pact> (xor 127 64)63pact> (xor 5 -7)-4
bash
pact> (xor 127 64)63pact> (xor 5 -7)-4

|

x integer y integer  integer

Compute bitwise X or Y.

bash
pact> (| 2 3)3pact> (| 5 -7)-3
bash
pact> (| 2 3)3pact> (| 5 -7)-3

~

x integer  integer

Reverse all bits in X.

bash
pact> (~ 15)-16
bash
pact> (~ 15)-16