Skip to main content

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.

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

&

x integer y integer  integer

Compute bitwise X and Y.

pact> (& 2 3)
2
pact> (& 5 -7)
1
pact> (& 2 3)
2
pact> (& 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.

pact> (* 0.5 10.0)
5.0
pact> (* 3 5)
15
pact> (* 0.5 10.0)
5.0
pact> (* 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.

pact> (+ 1 2)
3
pact> (+ 5.0 0.5)
5.5
pact> (+ "every" "body")
"everybody"
pact> (+ [1 2] [3 4])
[1 2 3 4]
pact> (+ { "foo": 100 } { "foo": 1, "bar": 2 })
{"bar": 2,"foo": 100}
pact> (+ 1 2)
3
pact> (+ 5.0 0.5)
5.5
pact> (+ "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.

pact> (- 1.0)
-1.0
pact> (- 3 2)
1
pact> (- 1.0)
-1.0
pact> (- 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.

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

<

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

True if X < Y.

pact> (< 1 3)
true
pact> (< 5.24 2.52)
false
pact> (< "abc" "def")
true
pact> (< 1 3)
true
pact> (< 5.24 2.52)
false
pact> (< "abc" "def")
true

<=

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

True if X <= Y.

pact> (<= 1 3)
true
pact> (<= 5.24 2.52)
false
pact> (<= "abc" "def")
true
pact> (<= 1 3)
true
pact> (<= 5.24 2.52)
false
pact> (<= "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.

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

>

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

True if X > Y.

pact> (> 1 3)
false
pact> (> 5.24 2.52)
true
pact> (> "abc" "def")
false
pact> (> 1 3)
false
pact> (> 5.24 2.52)
true
pact> (> "abc" "def")
false

>=

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

True if X >= Y.

pact> (>= 1 3)
false
pact> (>= 5.24 2.52)
true
pact> (>= "abc" "def")
false
pact> (>= 1 3)
false
pact> (>= 5.24 2.52)
true
pact> (>= "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.

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

abs

x decimal  decimal

x integer  integer

Absolute value of X.

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

and

x bool y bool  bool

Boolean logic with short-circuit.

pact> (and true false)
false
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.

pact> (and? (> 20) (> 10) 15)
false
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.

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

dec

x integer  decimal

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

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

exp

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

Exp of X.

pact> (round (exp 3) 6)
20.085537
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.

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

ln

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

Natural log of X.

pact> (round (ln 60) 6)
4.094345
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.

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

mod

x integer y integer  integer

X modulo Y.

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

not

x bool  bool

Boolean not.

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

not?

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

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

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

or

x bool y bool  bool

Boolean logic with short-circuit.

pact> (or true false)
true
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.

pact> (or? (> 20) (> 10) 15)
true
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.

pact> (round 3.5)
4
pact> (round 100.15234 2)
100.15
pact> (round 3.5)
4
pact> (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.

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

sqrt

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

Square root of X.

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

xor

x integer y integer  integer

Compute bitwise X xor Y.

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

|

x integer y integer  integer

Compute bitwise X or Y.

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

~

x integer  integer

Reverse all bits in X.

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

Receive important developer updates