Functions
add core
fn (x: Int | Dec, y: Int | Dec): Int | Dec
Add x and y.
Example
add(2, 3) // 5
add(1.5, 2.5) // 4.0
add(-1, 1) // 0
ceil core
fn (x: Int | Dec): Int
Round x up to the nearest integer.
Example
ceil(2.3) // 3
ceil(2.0) // 2
ceil(-2.3) // -2
div core
fn (x: Int | Dec, y: Int | Dec): Int | Dec
Divide x by y.
Example
div(10, 2) // 5
div(7, 2) // 3.5
div(1, 4) // 0.25
floor core
fn (x: Int | Dec): Int
Round x down to the nearest integer.
Example
floor(2.7) // 2
floor(2.0) // 2
floor(-2.3) // -3
is-neg core
fn (x: Int | Dec): Bool
Return true if x is less than zero.
Example
is-neg(-5) // true
is-neg(0) // false
is-neg(3) // false
is-pos core
fn (x: Int | Dec): Bool
Return true if x is greater than zero.
Example
is-pos(5) // true
is-pos(0) // false
is-pos(-3) // false
is-zero core
fn (x: Int | Dec): Bool
Return true if x is zero.
Example
is-zero(0) // true
is-zero(1) // false
is-zero(0.0) // true
mod core
fn (x: Int | Dec, y: Int | Dec): Int | Dec
Remainder of x divided by y.
Example
mod(10, 3) // 1
mod(7, 2) // 1
mod(8, 4) // 0
mod(2.5, 1) // 0.5
mul core
fn (x: Int | Dec, y: Int | Dec): Int | Dec
Multiply x by y.
Example
mul(3, 4) // 12
mul(2.5, 4) // 10.0
mul(-2, 3) // -6
pow core
fn (base: Int | Dec, exp: Int | Dec): Int | Dec
Raise base to the power exp.
Example
pow(2, 3) // 8
pow(10, 2) // 100
pow(2, 0) // 1
pow(1.5, 2) // 2.25
rand core
fn (): Dec
fn (n: Int): Dec
Random decimal between 0 and 1, or 0..n when n provided.
Example
rand() // 0.7234... (random decimal 0-1)
rand(10) // 7.234... (random decimal 0-10)
rand(100) // 72.34... (random decimal 0-100)
rand-int core
fn (): Int
fn (n: Int): Int
Random integer: 0 to max int, or 0 to n-1 when n provided.
Example
rand-int() // Random integer
rand-int(10) // Random integer 0-9
rand-int(6) // Random integer 0-5 (like a die roll minus 1)
round core
fn (x: Int | Dec): Int
Round x to the nearest integer.
Example
round(2.3) // 2
round(2.5) // 3
round(2.7) // 3
round(-2.5) // -2
sub core
fn (x: Int | Dec, y: Int | Dec): Int | Dec
Subtract y from x.
Example
sub(5, 3) // 2
sub(1, 5) // -4
sub(3.5, 1.5) // 2.0