Skip to main content
This page reflects what’s currently implemented in the interpreter (alpha). If something here behaves differently, please file an issue.

Testing

assert(condition[, message])

Asserts that a condition is true.
query assert(1 + 1 == 2)
query assert(2 + 2 == 5, "math is broken")
  • condition must be a boolean.
  • message (optional) must be a string.

assert_eq(a, b)

Asserts that two values are equal.
query assert_eq(2 + 2, 4)

Output

Prints values to stdout (space-separated) and returns nil.
query print("hello", 123, [1, 2, 3])

Lists and strings

count(list)

Returns the number of elements in a list.
query count([10, 20, 30])  // 3

first(list) / last(list)

Returns the first/last element of a list. If the list is empty, returns nil.
query first([10, 20, 30])
query last([10, 20, 30])
query first([])            // nil

length(x)

Returns the length of a list or a string.
query length([1, 2, 3])
query length("tide")

Math

sum(list)

Sums numeric elements of a list and returns an integer.
query sum([1, 2, 3, 4])
query sum(1..100)

abs(x)

Absolute value.
query abs(-5)

min(a, b) / max(a, b)

Returns the minimum/maximum of two numbers.
query min(10, 20)
query max(10, 20)

min(list) / max(list)

Returns the minimum/maximum element of a list. If the list is empty, returns nil.
query min([3, 1, 2])
query max([3, 1, 2])
query max([])  // nil