Reference

Function reference

Every builtin, one page each, with what it does, examples whose outputs were made by running them, the edge cases, what it gives back when it fails, and how it reads in a pipeline. 340 functions in 27 groups; Standard library is the overview, and each page takes comments and code samples at the foot.

General

FunctionWhat it does
print (any...) -> nullWrites its arguments to stdout as one line, each as text and a space between them, and gives null.
args () -> listWhat followed -- on the command line, as a list of text, for a script: quillo run tool.qwe -- a b gives ["a", "b"].
str (any) -> strThe value as text, written the way print writes it: a string is itself, a number its digits, a whole float with .0 and never in exponent form, a decimal its digits, a boolean true or false, null the word null, and a list or map as Quillo writes it, strings inside them quoted.
int (any) -> int | error(str)The value as an int.
float (any) -> float | error(str)The value as a float.
format_number (num | dec, str | null=, int | map | null=, str=) -> strA number as a locale writes it: grouped digits, the locale's decimal mark and its minus sign.
len (str | list | map | html | null) -> intThe size of a value: a string's characters, a list's items, a map's keys, and an html value's bytes.
type_of (any) -> strThe kind of a value as text: one of null, bool, int, float, dec, str, list, map, fn, html, response and error.
env (str, any=) -> anyThe value of an environment variable, as a string, or null when it is not set; with a second argument, that default instead of null.
platform () -> mapWhere the program runs, as a map.
random () -> floatA float from 0 up to, but not including, 1, different on each call.
random_int (int, int) -> intAn int from lo to hi, both ends included, different on each call.
uuid () -> strA new version 4 UUID as text: 36 characters, lower-case hex in five groups of 8, 4, 4, 4 and 12, with a 4 at the start of the third group.

Strings

FunctionWhat it does
cursor_index (str, int) -> intThe place in s, in characters, of a field's cursor at n: a field's selectionStart counts UTF-16 units, as JavaScript does, and slice, len and s[i] count characters.
upper (str) -> strThe text in upper case.
lower (str) -> strThe text in lower case.
normalize (str, str | null=) -> strThe text in one Unicode form, so that text which looks the same is the same.
trim (str) -> strThe text without the whitespace at its start and end: spaces, tabs, newlines and carriage returns, and the rest of Unicode's White_Space as well (U+0085 too, but not U+FEFF, a byte-order mark), the same in the browser.
split (str, str=) -> listCuts text at every occurrence of a separator and gives the pieces as a list of strings.
join (list | null, str=) -> strThe items of a list as one string, with a separator between them; without a separator they are put side by side.
contains (str | list | map | null, any) -> boolWhether a value holds another: in a string, the second argument as text; in a list, an item equal to it (as == says); in a map, a key with that name.
starts_with (str, str) -> boolWhether the text begins with a prefix.
ends_with (str, str) -> boolWhether the text ends with a suffix.
replace (str, str, str) -> strThe text with every occurrence of one piece replaced by another.
slice (list | str, int, int=) -> list | strThe part of a list or a string from a start position up to, but not including, an end position; without an end, up to the end.
index_of (list | str, any) -> int | nullThe position of a value in a list or of a piece of text in a string, counting from 0, or null when it is not there: null, not -1.
repeat (str, int) -> strThe text written a number of times in a row.

Regular expressions

FunctionWhat it does
re.valid (any, str | null=) -> boolWhether a pattern can be run, for one that comes from data or a person.
re.test (str, str, str | null=) -> boolWhether a pattern matches anywhere in the text: true or false, nothing about where.
re.find (str, str, str | null=) -> map | nullThe first match of a pattern in the text, or null when there is none.
re.find_all (str, str, str | null=) -> listEvery match of a pattern in the text, from left to right, as a list of matches, each { text, start, end, groups, named } as re.find gives it.
re.replace (str, str, str | fn, str | null=) -> strThe text with every match of a pattern replaced.
re.split (str, str, str | null=) -> listThe text cut at every match of a pattern, as a list of the pieces between the matches.

Lists

FunctionWhat it does
map (list | null, fn) -> listA new list with the function applied to each item, in order.
filter (list | null, fn) -> listThe items for which the function gives a true value, in their original order, as a new list.
find (list | null, fn) -> anyThe first item for which the function gives a true value, or null when none does.
any (list | null, fn) -> booltrue when the function gives a true value for at least one item, else false.
all (list | null, fn) -> booltrue when the function gives a true value for every item, else false.
reduce (list | null, any, fn) -> anyFolds the list into one value.
sum (list | null) -> anyThe items added together, starting from 0.
min (list | null) -> anyThe smallest item of a list, or null when the list is empty.
max (list | null) -> anyThe largest item of a list, or null when the list is empty.
sort (list | null) -> listThe items in ascending order, as a new list.
sort_by (list | null, fn) -> listThe items in ascending order of a key, as a new list.
reverse (list | str) -> list | strA list with its items in the opposite order, or a string with its characters in the opposite order.
first (list | null) -> anyThe first item of a list, or null when the list is empty.
last (list | null) -> anyThe last item of a list, or null when the list is empty.
push (list | null, any=) -> listA new list with one item added at the end.
range (int, int=, int=) -> listA list of ints.
enumerate (list | null) -> listA list of pairs [index, item], one for each item, the index counting from 0.
unique (list | null) -> listThe list without repeats: the first of each group of equal items, in the order they first appear.
flatten (list | null) -> listOne list from a list of lists: the items of each inner list, in order, one level deep.
zip (list | null, list | null) -> listPairs the two lists item by item: a list of [a, b] lists, the first of each, then the second, and so on, as long as the shorter list.
take (list | str | null, int) -> list | strThe first n items of a list, or the first n characters of a string, as a new value.
drop (list | str | null, int) -> list | strThe list without its first n items, or the string without its first n characters, as a new value.
count (list | null, fn=) -> intHow many items there are, or, with a function, how many of them the function says yes to.
group_by (list | null, fn) -> mapA map from each key to the list of items with that key, the key being what the function gives for the item.
join_on (list | null, list | null, str, str | null=, str | null=) -> listJoins two lists of rows (maps) on a key, as a left join: each row of the first list comes back with one more field holding its match from the second list, or null when there is none.

Maps

FunctionWhat it does
keys (map | null) -> listThe keys of a map, as a list of strings, in the order the entries were added.
values (map | null) -> listThe values of a map as a list, in the order the entries were added.
get (map | null, any, any=) -> anyThe value under a key, or the default when the key is not in the map; without a default, null.
has (map | null, any) -> boolWhether a map has an entry under a key: true or false.
set (map | list | null, any, any=) -> map | listA new map with one entry set, or a new list with one item replaced.
remove (list | map | null, any) -> list | mapA new map without one key, or a new list without every item equal to a value.
merge (map | null, map | null) -> mapOne map made of two: every entry of the first, then every entry of the second, which wins where both have a key.

Records and errors

FunctionWhat it does
error (any) -> anyWhat an error value says, and null for any other value, so it can be asked of anything: a value that did not fail has no error, whatever it is.
err (any=) -> error(any)An error value carrying a payload: text, a number, a map, anything.
is_err (any) -> boolWhether a value is an error value: true for anything made by err or returned as an error by a builtin such as int("x"), false for everything else, null included.
unwrap (any) -> anyThe value itself when it is not an error value, and a runtime error when it is.

JSON

FunctionWhat it does
json.parse (str) -> anyThe value written in a JSON text: an object becomes a map, an array a list, a string a str, true and false booleans, null null.
json.stringify (any, any=) -> strThe value as JSON text, on one line with no spaces.

Math

FunctionWhat it does
abs (num | dec) -> num | decThe absolute value: the number without its sign.
round (num | dec, int=, str=) -> num | decThe number rounded.
floor (num | dec) -> num | decThe largest whole number not above the argument: 2.7 gives 2, -2.7 gives -3.
ceil (num | dec) -> num | decThe smallest whole number not below the argument: 2.1 gives 3, -2.1 gives -2.
sqrt (num) -> floatThe square root, always a float: sqrt(16) is 4.0.
pow (num | dec, num) -> num | decx to the power y.
math.sqrt (num) -> floatThe square root of a number, as a float, the way Python's math.sqrt gives it.
math.cbrt (num) -> floatThe cube root of a number, as a float, as Python's math.cbrt.
math.exp (num) -> floate raised to the power of the number, as a float, as Python's math.exp.
math.exp2 (num) -> float2 raised to the power of the number, as a float, as Python's math.exp2.
math.expm1 (num) -> floate to the power of the number, minus one, as a float, as Python's math.expm1.
math.log (num, num=) -> floatThe natural logarithm of a number, as a float, as Python's math.log.
math.log2 (num) -> floatThe logarithm of a number to base 2, as a float, as Python's math.log2.
math.log10 (num) -> floatThe logarithm of a number to base 10, as a float, as Python's math.log10.
math.log1p (num) -> floatThe natural logarithm of one plus the number, as a float, as Python's math.log1p.
math.pow (num, num) -> floatThe first number raised to the power of the second, always as a float, as Python's math.pow.
math.sin (num) -> floatThe sine of an angle in radians, as a float, as Python's math.sin.
math.cos (num) -> floatThe cosine of an angle in radians, as a float, as Python's math.cos.
math.tan (num) -> floatThe tangent of an angle in radians, as a float, as Python's math.tan.
math.asin (num) -> floatThe arc sine: the angle in radians, between -pi/2 and pi/2, whose sine is the number, as Python's math.asin.
math.acos (num) -> floatThe arc cosine: the angle in radians, between 0 and pi, whose cosine is the number, as Python's math.acos.
math.atan (num) -> floatThe arc tangent: the angle in radians, between -pi/2 and pi/2, whose tangent is the number, as Python's math.atan.
math.atan2 (num, num) -> floatThe angle in radians, between -pi and pi, from the positive x axis to the point (x, y), as Python's math.atan2.
math.sinh (num) -> floatThe hyperbolic sine of a number, as a float, as Python's math.sinh: (e^x - e^-x) / 2.
math.cosh (num) -> floatThe hyperbolic cosine of a number, as a float, as Python's math.cosh: (e^x + e^-x) / 2.
math.tanh (num) -> floatThe hyperbolic tangent of a number, as a float, as Python's math.tanh: sinh(x) / cosh(x).
math.asinh (num) -> floatThe inverse hyperbolic sine: the number whose math.sinh is the argument, as a float, as Python's math.asinh.
math.acosh (num) -> floatThe inverse hyperbolic cosine: the number, zero or above, whose math.cosh is the argument, as a float, as Python's math.acosh.
math.atanh (num) -> floatThe inverse hyperbolic tangent: the number whose math.tanh is the argument, as a float, as Python's math.atanh.
math.degrees (num) -> floatAn angle in radians as degrees, a float, as Python's math.degrees: the number times 180 / pi.
math.radians (num) -> floatAn angle in degrees as radians, a float, as Python's math.radians: the number times pi / 180.
math.hypot (num...) -> floatThe Euclidean length of a vector given as separate numbers: the square root of the sum of their squares, as a float, as Python's math.hypot.
math.dist (list, list) -> floatThe Euclidean distance between two points, each a list of numbers of the same length, as a float, as Python's math.dist.
math.floor (num) -> intThe largest int that is not above the number, as Python's math.floor.
math.ceil (num) -> intThe smallest int that is not below the number, as Python's math.ceil.
math.trunc (num) -> intThe number with its fraction dropped, as an int: rounding toward zero, as Python's math.trunc.
math.fabs (num) -> floatThe absolute value, always as a float, as Python's math.fabs: math.fabs(-3) is 3.0.
math.copysign (num, num) -> floatThe first number's magnitude with the second number's sign, as a float, as Python's math.copysign: math.copysign(3, -1) is -3.0.
math.fmod (num, num) -> floatThe remainder of dividing the first number by the second, with the sign of the first, as a float: C's fmod and Python's math.fmod.
math.remainder (num, num) -> floatThe IEEE remainder: the first number minus the multiple of the second that is closest to it, as a float, as Python's math.remainder.
math.modf (num) -> listThe fractional and the integer part of a number, as a list of two floats, [fraction, whole], as Python's math.modf: math.modf(3.75) is [0.75, 3.0].
math.frexp (num) -> listA number taken apart into a mantissa and an exponent of two, as a list [m, e] with x == m * 2^e and 0.5 <= |m| < 1, as Python's math.frexp.
math.ldexp (num, int) -> floatx * 2^e, as a float, as Python's math.ldexp: the inverse of math.frexp.
math.factorial (int) -> intn!, the product of the ints from 1 to n, as an int, as Python's math.factorial.
math.gcd (int | list...) -> intThe greatest common divisor of some ints, as Python's math.gcd: the largest int that divides each of them.
math.lcm (int | list...) -> intThe least common multiple of some ints, as Python's math.lcm: the smallest positive int that each of them divides.
math.comb (int, int) -> intThe number of ways to choose k items from n without regard to order, the binomial coefficient, as an int, as Python's math.comb: math.comb(52, 5) is 2598960, the poker hands.
math.perm (int, int | null=) -> intThe number of ways to pick k items from n in order, n! / (n - k)!, as an int, as Python's math.perm: math.perm(5, 2) is 20.
math.isqrt (int) -> intThe integer square root: the largest int whose square is not above n, as Python's math.isqrt.
math.isclose (num, num, num=, num=) -> boolWhether two numbers are close enough to count as equal, as Python's math.isclose: math.isclose(a, b, rel_tol, abs_tol) is true when |a - b| is within rel_tol times the larger of |a| and |b|, or within abs_tol.
math.isfinite (num) -> boolWhether a number is neither infinite nor NaN, as Python's math.isfinite.
math.isinf (num) -> boolWhether a number is positive or negative infinity, as Python's math.isinf.
math.isnan (num) -> boolWhether a float is NaN, "not a number", as Python's math.isnan.
math.prod (list | null, num=) -> numThe product of a list of numbers, as Python's math.prod, times a start value that is 1 by default.
math.fsum (list | null) -> floatThe sum of a list of numbers as a float, rounded once at the end, as Python's math.fsum (Shewchuk's algorithm): every item's bits count, so the answer is the exactly rounded sum where sum accumulates rounding errors.
math.sumprod (list, list) -> numThe sum of the products of two lists item by item, a dot product, as Python's math.sumprod: math.sumprod([1, 2, 3], [4, 5, 6]) is 4 + 10 + 18, 32.
math.erf (num) -> floatThe error function, as Python's math.erf: 2 / sqrt(pi) times the integral of exp(-t²) from 0 to x.
math.erfc (num) -> floatThe complementary error function, 1 - erf(x), as Python's math.erfc, computed so that the small values in the tail keep their digits: 1 - math.erf(5) has lost most of them to cancellation, math.erfc(5) has not.
math.gamma (num) -> floatThe gamma function, as Python's math.gamma: the factorial extended to any number, as a float, with math.gamma(n) equal to (n - 1)! for a positive int n.
math.lgamma (num) -> floatThe natural logarithm of the absolute value of the gamma function, as Python's math.lgamma: math.lgamma(x) is log(|gamma(x)|), computed without forming gamma(x) itself, so it works far past where math.gamma overflows.

Statistics

FunctionWhat it does
stats.mean (list) -> floatThe arithmetic mean of a list of numbers, as a float: the sum divided by the count.
stats.fmean (list, list | null=) -> floatThe mean of a list of numbers as a float, optionally weighted.
stats.geometric_mean (list) -> floatThe geometric mean of a list of positive numbers: the n-th root of their product, computed through logarithms as Python's statistics.geometric_mean does.
stats.harmonic_mean (list) -> floatThe harmonic mean of a list of numbers that are zero or more: the count divided by the sum of the reciprocals, as Python's statistics.harmonic_mean.
stats.median (list) -> numThe middle value of a list of numbers, as Python's statistics.median.
stats.median_low (list) -> numThe low median of a list of numbers: always one of the data points.
stats.median_high (list) -> numThe high median of a list of numbers: always one of the data points.
stats.mode (list) -> anyThe most common value in a list, as Python's statistics.mode.
stats.multimode (list | null) -> listEvery most common value in a list, in the order each was first seen, as Python's statistics.multimode.
stats.pvariance (list, num | null=) -> floatThe population variance of a list of numbers: the mean of the squared distances from the mean, dividing by the count.
stats.variance (list, num | null=) -> floatThe sample variance of a list of numbers: the sum of the squared distances from the mean, divided by one less than the count (Bessel's correction).
stats.pstdev (list, num | null=) -> floatThe population standard deviation of a list of numbers: the square root of stats.pvariance, as Python's statistics.pstdev.
stats.stdev (list, num | null=) -> floatThe sample standard deviation of a list of numbers: the square root of stats.variance, as Python's statistics.stdev.
stats.quantiles (list, int=, str=) -> listThe cut points that divide a list of numbers into n parts of equal probability, as Python's statistics.quantiles: n - 1 floats in rising order.
stats.percentile (list, num | list) -> anyThe value below which p percent of a list of numbers lies, with p from 0 to 100, by numpy's default rule: the sorted data is laid out from 0 to 100 and the answer is interpolated linearly between the two closest data points.
stats.covariance (list, list) -> floatThe sample covariance of two lists of numbers of the same length: how much they vary together, as Python's statistics.covariance.
stats.correlation (list, list, str=) -> floatPearson's correlation coefficient of two lists of numbers of the same length, from -1 to 1, as Python's statistics.correlation: 1 when the pairs lie on a rising line, -1 on a falling one, 0 when there is no linear relation.
stats.linear_regression (list, list, bool=) -> mapThe line y = slope * x + intercept that fits two lists of numbers of the same length best, by least squares, as Python's statistics.linear_regression.
stats.describe (list | null) -> mapA summary of a list of numbers in one map, as a data frame's describe: { count, sum, mean, std, min, q1, median, q3, max }.
stats.histogram (list | null, int | list=) -> mapCounts a list of numbers into bins, as numpy's histogram: a map { counts, edges } where edges has one more float than counts has ints.
stats.zscore (list | null) -> listEach number of a list as a standard score: how many standard deviations it is from the list's mean, as a list of floats in the same order.
stats.normalize (list | null) -> listEach number of a list scaled to 0..1: the smallest value becomes 0.0, the largest 1.0, and the rest keep their proportions between them.
stats.rank (list | null) -> listThe rank of each number in a list, counting from 1 for the smallest, as a list in the same order as the data.
stats.normal_pdf (num, num=, num=) -> floatThe probability density of a normal distribution at x: the height of the bell curve there, as Python's NormalDist(mu, sigma).pdf(x).
stats.normal_cdf (num, num=, num=) -> floatThe cumulative probability of a normal distribution at x: the share of the distribution that lies at or below x, from 0 to 1, as Python's NormalDist(mu, sigma).cdf(x).
stats.normal_inv (num, num=, num=) -> floatThe inverse of stats.normal_cdf: the x below which a share p of a normal distribution lies, with p strictly between 0 and 1, as Python's NormalDist(mu, sigma).inv_cdf(p) (Wichura's algorithm AS241).

Vectors

FunctionWhat it does
vec.add (list | num, list | num) -> anyAdds item by item: two lists of the same length give a list of their pairwise sums, and a list and a number give the list with the number added to each item.
vec.sub (list | num, list | num) -> anySubtracts item by item: two lists of the same length give a list of their pairwise differences, a list and a number give the list with the number taken from each item, and a number and a list give the number less each item.
vec.mul (list | num, list | num) -> anyMultiplies item by item: two lists of the same length give a list of their pairwise products, and a list and a number give the list with each item scaled by the number.
vec.div (list | num, list | num) -> anyDivides item by item: two lists of the same length give a list of their pairwise quotients, a list and a number give the list with each item divided by the number, and a number and a list give the number divided by each item.
vec.mod (list | num, list | num) -> anyThe remainder item by item, as the % operator gives it: two lists of the same length pair up, or a list and a number.
vec.pow (list, num) -> listEach item raised to a power.
vec.dot (list, list) -> numThe dot product of two lists of the same length: the sum of the pairwise products.
vec.norm (list, num=) -> floatThe length of a list of numbers as a vector: without p, or with p of 2, the square root of the sum of the squares.
vec.cumsum (list | null) -> listThe running total: a list where each item is the sum of the input up to and including that position.
vec.cumprod (list | null) -> listThe running product: a list where each item is the product of the input up to and including that position.
vec.diff (list | null) -> listThe difference between each item and the one before it: a list one shorter than the input, where item i is xs[i + 1] - xs[i].
vec.argmin (list | null) -> int | nullThe position of the smallest number in a list, counting from 0.
vec.argmax (list | null) -> int | nullThe position of the largest number in a list, counting from 0.
vec.argsort (list | null, bool=) -> listThe positions that would put a list of numbers in ascending order: vec.argsort([30, 10, 20]) is [1, 2, 0], since item 1 is the smallest.
vec.clip (list, num | null, num | null=) -> listEach item kept within a lower and an upper bound: an item below lo becomes lo, an item above hi becomes hi, the rest stay as they are.
vec.abs (list) -> listEach item's absolute value: negatives turned positive, the rest as they are.
vec.sqrt (list) -> listThe square root of each item, as a list of floats.
vec.exp (list) -> liste raised to each item, as a list of floats.
vec.log (list) -> listThe natural logarithm of each item, as a list of floats.
vec.round (list, int=) -> listEach item rounded.
vec.linspace (num, num, int=, bool=) -> listn evenly spaced floats from start to stop, both included; n is 50 when left out.
vec.arange (num, num=, num=) -> listNumbers from start up to but not including stop, step apart.
vec.zeros (int) -> listA list of n ints, all 0.
vec.ones (int) -> listA list of n ints, all 1.
vec.full (int, any) -> listA list of n copies of a value.
vec.rolling_mean (list, int) -> listThe moving average: the mean of each run of window neighbouring items, as a list of floats.
vec.rolling_sum (list, int) -> listThe sum of each run of window neighbouring items, as a list of floats.
vec.matmul (list, list) -> listMatrix multiplication.
vec.transpose (list | null) -> listRows turned into columns: for a list of rows of one length, a list of the columns, each the items at one position of every row.
vec.column (list | null, str | int) -> listOne column out of a list of rows.

Dates

FunctionWhat it does
now () -> intThe time now as milliseconds since 1970-01-01T00:00:00Z, an int: the clock for measuring how long something took, for timestamps stored as numbers and for max_age-style arithmetic.
sleep (num) -> nullWaits that many milliseconds, then gives null.
date.today (str | null=) -> strThe calendar date now, as ISO text "YYYY-MM-DD", in UTC.
date.now (str | null=) -> strThe date and time now, to the second, as RFC 3339 text: "2026-10-27T14:30:00Z" in UTC.
date.parse (str, str | null=) -> str | error(str)Reads text as a date or a date-time and gives it back in the form the date module uses: "2026-10-27" or "2026-10-27T14:30:00Z".
date.valid (any, str | null=) -> boolWhether a value is text the date module accepts: a date "YYYY-MM-DD" that is a real day, or a date-time "YYYY-MM-DDTHH:MM:SS" with an offset (Z, +01:00).
date.valid_zone (any) -> boolWhether a value is a time zone: a name of the IANA database, a zone or a link, in any case ("Europe/Paris", "US/Pacific", "EST"), an offset as date.parse reads one ("+05:45", "+0530", "+05", up to +23:59), or "UTC".
date.of (int, int, int) -> strThe date with a year, a month and a day, as ISO text "YYYY-MM-DD".
date.parts (str) -> mapA date taken apart: a map { year, month, day, weekday } of ints, weekday 1 for Monday to 7 for Sunday.
date.weekday (str) -> intThe day of the week of a date, as an int: 1 for Monday to 7 for Sunday (ISO 8601).
date.is_leap_year (int | str) -> boolWhether a year has a 29th of February: true for years divisible by 4, except centuries, except those divisible by 400 (the Gregorian rule).
date.days_in_month (int | str, int=) -> intHow many days a month has: 28 to 31.
date.add_days (str, int) -> strA date some days later, or earlier with a negative count, as ISO text.
date.add_months (str, int) -> strThe same day of the month some months on, or back with a negative count, as ISO text.
date.add_years (str, int) -> strThe same month and day some years on, or back with a negative count, as ISO text.
date.days_between (str, str) -> intThe number of days from one date to another, the second minus the first: the nights of a stay, the age of an order in days.
date.months_between (str, str) -> intThe number of whole months from one date to another: the largest count that date.add_months can add to the first date without passing the second.
date.start_of_month (str) -> strThe first day of a date's month, as ISO text: "2026-10-27" gives "2026-10-01".
date.end_of_month (str) -> strThe last day of a date's month, as ISO text: the 28th, 29th, 30th or 31st, the leap year taken into account.
date.to_zone (str, str | null=) -> strThe same instant written at a time zone's offset: "2026-10-27T14:30:00Z" in "Europe/Paris" is "2026-10-27T15:30:00+01:00".
date.date_in (str, str | null=) -> strThe calendar date of a date-time in a time zone: what day it is there at that instant, as ISO text "YYYY-MM-DD".
date.at (str, str | null=, str | map | null=, map | null=) -> strThe instant a local time names: a date, a time of day "HH:MM" or "HH:MM:SS", and a time zone, as a date-time written at that zone's offset.
date.compare (str, str) -> int-1, 0 or 1 as a is before, at or after b, by the instants they name: a fraction of a second, an offset and the way each is written do not matter.
date.format (str, str | map) -> strA date or a date-time as text, by a pattern or in a locale's style.
date.ms (str) -> intA date-time as milliseconds since 1970-01-01T00:00:00Z, the number now() gives, so times can be subtracted, compared across offsets and stored as ints.
date.from_ms (int, str | null=) -> strMilliseconds since 1970, as now() or date.ms give them, as a date-time to the second: "2026-11-01T14:30:00Z".

Decimals and money

FunctionWhat it does
dec (any) -> dec | error(str)The value as a decimal: an exact number with a fixed count of decimals, for money and whatever else is counted in cents.
money.of (dec | int | str, str, str=) -> map | error(str)An amount of money: a plain map { amount: dec, currency: "USD" }, the amount with exactly the currency's minor units (ISO 4217: USD 2, JPY 0, KWD 3).
money.parse (str, str, str | null=, str=) -> map | error(str)An amount read as a locale writes it, made money of a currency: what a person types in a form.
money.from_minor (int, str) -> map | error(str)An amount from a whole number of its currency's minor units: money.from_minor(1250, "USD") is 12.50 dollars, money.from_minor(1250, "JPY") 1250 yen and money.from_minor(1250, "KWD") 1.250 dinars.
money.to_minor (map) -> intThe amount as an int of its currency's minor units: cents for USD, yen for JPY, fils for KWD.
money.add (map, map) -> map | error(str)The sum of two amounts of one currency, as money of that currency.
money.sub (map, map) -> map | error(str)The first amount less the second, as money of their currency.
money.mul (map, dec | int, str=) -> map | error(str)An amount times a factor, a decimal or an int, rounded to the currency's decimals: half to even unless a rounding mode (those of round) says otherwise.
money.neg (map) -> map | error(str)The amount with its sign flipped, in the same currency: a charge becomes a refund, a debit a credit.
money.compare (map, map) -> intHow two amounts of one currency stand: -1 when the first is smaller, 0 when they are equal, 1 when it is larger.
money.zero (str) -> map | error(str)Nothing of a currency: { amount: 0.00, currency: "USD" }, the zero written with the currency's minor units (0 for JPY, 0.000 for KWD).
money.is_zero (map) -> boolWhether an amount is nothing: true for zero in any currency, false for any other amount, positive or negative.
money.allocate (map, list | int) -> listAn amount split into shares by ratios, without losing or making a minor unit: a list of money, one per ratio, that adds up to the amount exactly.
money.round (map, str=) -> map | error(str)The amount rounded to its currency's decimals, half to even unless a rounding mode (those of round) says otherwise.
money.minor_units (str) -> int | error(str)How many decimals a currency has, from ISO 4217: 2 for USD and EUR (cents), 0 for JPY and KRW, 3 for KWD and BHD (fils).
money.format (map, str | null=) -> strThe amount written for people, as CLDR has it for a locale and as Intl.NumberFormat writes it in a browser: $1,234.50 in en-US, 1.234,50 € in de-DE, 1 234,50 € in fr-FR, ¥1,235 in ja-JP, ₹12,34,567.00 in en-IN.

Markup

FunctionWhat it does
raw (any) -> htmlMarks text as trusted HTML: the result is an html value, which markup writes as it is instead of escaping it.
escape (any) -> strThe value's text with & < > " ' written as entities (&amp; &lt; &gt; &quot; &#39;), safe to put inside an element or an attribute.
classes () -> listThe classes the program's markup writes, sorted, each once: the .class shorthand (<div.card.p-4>), class="..." attributes, the text in class={...} (both sides of a ? :, for instance) and class:name={...}, in every file of the program.
markdown (str, map | null=) -> htmlMarkdown text as HTML: CommonMark with tables, strikethrough and task lists.
markdown_page (str, map | null=) -> htmlMarkdown text as a whole HTML page, for a route to answer with: what markdown makes, inside a doctype, an <html>, and a <head> with <meta charset="utf-8">, a viewport and a <title>.
highlight (str, str | null=) -> htmlSource code as HTML, escaped, with its keywords, strings, comments and so on wrapped in spans: hl-k keywords, hl-s strings, hl-c comments, hl-n numbers and constants, hl-f functions called, hl-t types and tags, hl-a attributes, properties and keys.
css (str) -> strThe text as it is.

Translations

FunctionWhat it does
translations (str | map, map | null=) -> nullDeclares the program's translations, at the top of the program, for t and locale.
locale_from (fn) -> nullDeclares how a request's locale is chosen: the function is given the request and gives a locale name (a query parameter, a signed-in user's setting), which is matched to the program's translations as Accept-Language is (fr-CA is served by fr).
locale () -> str | nullThe locale the code runs in, as named in translations: "en", "pt-BR".
with_locale (str, fn) -> anyRuns a function in another locale and gives what the function gives: t and locale inside it use that locale, and the request's own locale is back afterwards.
t (str, map | null=) -> strThe key's text in the current locale, from the program's translations.

Web

FunctionWhat it does
url_encode (any) -> strThe value's text written for a URL: every byte but letters, digits and -_.~ becomes %XX.

Requests and pages

FunctionWhat it does
redirect (str, int=) -> responseA response that sends the browser to another address: a status of 303 unless one is given, and a location header with the URL.
local_path (any) -> str | nullnext if it is an address on this site, read as a browser reads it, else null.
respond (int, any=, map | null=) -> responseA response with exactly the status, body and headers given.
allow_cross_site (str) -> nullLets the routes under a path take form posts from pages on other sites.
site_headers (str | map, map=) -> nullHeaders sent with every answer that does not set them itself, written once at the top of the program: site_headers({ "content-security-policy": "default-src 'self'" }), or for the answers under a path, site_headers("/admin", { "cache-control": "no-store" }).
stream (fn, map | null=) -> responseA response sent as the function makes it.
events (fn, map | null=) -> responseA response of Server-Sent Events, sent as the function makes them.
ready (str, fn) -> nullAdds a check of the program's own to GET /_quillo/ready, which answers 200 when everything the program needs is there and 503 when not, with each part as JSON: its database (select 1), each service it declares, and the checks added here.
idempotent (map | fn, fn=) -> anyRuns the function once for a request, however many times the request is sent.

Cookies and sessions

FunctionWhat it does
set_cookie (str, any=, map | null=) -> nullAdds a Set-Cookie header to the request's answer, whatever the route returns, from anywhere in the request: a route, a server fn, a helper.
cookie (str) -> str | nullThe value of a cookie the browser sent with the request, decoded, or null when there is none of that name.
delete_cookie (str, map | null=) -> nullTells the browser to forget a cookie: a Set-Cookie for the name with an empty value and Max-Age=0 joins the request's answer, whatever the route returns.
session () -> mapThe visitor's session: the map set_session stored, read from the signed cookie the browser sent back, or {} when there is none.
set_session (map | null, map | null=) -> nullReplaces the visitor's session with the map and sends it to the browser as a cookie signed with HMAC-SHA256: the browser can read it but not change it.
end_session () -> nullForgets the visitor's session: the session cookie is removed from the browser with the request's answer, and session() is {} from here on.

Tenants

FunctionWhat it does
tenant () -> str | nullThe name of the tenant the code runs for, or null.
tenant_from (str | fn) -> nullSays how a request's tenant is found, at the top of a program.
with_tenant (str, fn) -> anyRuns the function for a tenant, with its database, its live updates, and its rooms of channels and its media streams, and gives what the function gives.
new_tenant (str, fn) -> anyMakes a tenant's database, migrates it, and runs the function for that tenant, giving what the function gives.

Database

FunctionWhat it does
sql_name (str | list) -> strA table's or a column's name, checked and quoted, for SQL that cannot take it as a ? parameter: "title", or `title` when the program's database is MySQL.
sql_param (str | list) -> strA named SQL parameter, :title, checked: the name is letters, digits and _ (of any script, as sql_name takes them), not starting with a digit and at most 63 bytes long.
sql (str) -> strThe text as it is.
db.open (str | fn, map=) -> null | error(str)Opens the program's database, the one db.exec, db.query, db.one and the rest use: a SQLite file by its path (from the program's folder, wherever Quillo runs; ":memory:" for one that lives in memory), or a server by URL (postgres://..., mysql://..., mariadb://...).
db.connect (str | fn, map=) -> map | error(str)Opens another database beside the program's own and gives it as a map of the same functions, called on it: analytics.query(...), analytics.exec(...), one, transaction, migrate, tenants, tenant_exists and sql_name.
db.system (str) -> null | error(str)Names the system database: where Quillo keeps its own tables, the scheduled jobs (_quillo_jobs), the decisions of db.atomic (_quillo_atomic) and the calls a service answered.
later.status (str) -> map | nullSays what became of a call made later, from the id .later gave:.
db.shards (list) -> map | error(str)Data split over several databases by a key (a customer, an account).
db.atomic (list, fn) -> anyOne transaction over several databases: runs the function and keeps all of its changes in the listed databases, or none.
db.exec (str, any...) -> map | error(str)Runs a statement that changes the database (insert, update, delete, create table) and gives { changes, last_id }: how many rows it matched, and the id of the one row an insert made (null after anything else, and always on PostgreSQL, where `insert ..
db.exec_many (str, list) -> map | error(str)Runs one statement for each row of a list, all of them or none, and gives { changes }: how many rows they touched in all.
db.query (str, any...) -> list | error(str)Runs a query and gives every row as a list of maps, keyed by column name; no rows is [].
db.one (str, any...) -> map | null | error(str)Runs a query and gives its first row as a map, or null when there is none: a record by id, a count, an `insert ..
db.transaction (map | fn, fn=) -> anyRuns a function with all of its database changes kept together: when the function fails, returns an error value or replies early, everything it did in the database is rolled back; otherwise it is committed and the function's value is given.
db.error_kind (any) -> str | nullWhat kind of failure a database's error value is, in one word that is the same for SQLite, PostgreSQL and MySQL, whose own messages differ: "unique" (a key or unique column has the value already), "foreign_key", "not_null", "check", or "conflict" (another transaction: the database busy, a deadlock, a serialization failure), or "connection" (the server ended the connection, or it could not be made) (since 0.7).
db.sql_name (str | list) -> strA table's or a column's name, checked and quoted for the database it is called on, for SQL that cannot take it as a ? parameter.
db.migrate (str=) -> list | error(str)Brings the database's schema up to date from a folder of SQL files, applied in name order (001_todos.sql, 002_tags.sql, ...), and gives the names of the files it applied this time.
db.tenants () -> list | error(str)The names of the tenants that have a database, when the program's database is one per tenant: db.open("data/{tenant}.db") lists the SQLite files there are, a ?schema=t_{tenant} target the PostgreSQL schemas, mysql://host/app_{tenant} the MySQL databases.
db.tenant_exists (str) -> boolWhether a tenant has a database, when the program's database is one per tenant: the SQLite file, PostgreSQL schema or MySQL database for that name exists.

HTTP client

FunctionWhat it does
http.get (str, map | null=, map | null=) -> map | error(str)Fetches a URL with GET and gives the answer as a map { status, ok, headers, body, json }: ok is true for a 2xx status, headers has its names in lower case, body is the text (bytes that are not UTF-8 replaced, cut at 64 MiB) and json is the body parsed as JSON, or null.
http.delete (str, map | null=, map | null=) -> map | error(str)Sends a DELETE to a URL, with no body, and gives the answer as a map { status, ok, headers, body, json }, as http.get does.
http.post (str, any=, map | null=, map | null=) -> map | error(str)Sends a POST with a body and gives the answer as a map { status, ok, headers, body, json }, as http.get does.
http.put (str, any=, map | null=, map | null=) -> map | error(str)Sends a PUT with a body, as http.post sends a POST, and gives the answer as a map { status, ok, headers, body, json }.
http.patch (str, any=, map | null=, map | null=) -> map | error(str)Sends a PATCH with a body, as http.post sends a POST, and gives the answer as a map { status, ok, headers, body, json }.
http.request (str, str, any=, map | null=, map | null=) -> map | error(str)Sends a request with any method: the method first, then the URL, a body, a map of headers and a map of options (redirects, public_only, cache for GET, timeout, ca, cert, key).
http.stream (str, fn, map | null=) -> map | error(str)Reads another server's answer as it arrives, calling f with each piece: each Server-Sent Event (its data, parsed as JSON when it is, and its name), each line of newline-delimited JSON, or each piece of plain text, by the answer's content-type.

Files and processes

FunctionWhat it does
stdin () -> str | error(str)All that is piped to a script, as text, read to the end: cat rows.csv | quillo run tool.qwe.
read_line () -> str | null | error(str)The next line a script is given, without its line break, or null at the end of what is piped in.
exit (int=) -> nullEnds a script at once with the status n, from 0 to 255, or 0 if it is left out, once what it printed is out: the status a shell's $?, a make rule or CI reads.
file (str, map | null=) -> responseA response that sends a file from the program's folder, for a route to answer with: route GET /report = file("exports/report.pdf").
files (str, str | null=, map | null=) -> responseA folder of files served as a static host serves it, for a route to answer with: route GET /*path = files("site", path).
read_file (str) -> str | error(str)The text of a file under the program's folder.
write_file (str, any) -> null | error(str)Writes a value as text to a file under the program's folder, replacing what was there, and makes the folders on the way.
delete_file (str) -> null | error(str)Removes a file under the program's folder, or a folder and everything in it.
check_program (str, map | null=) -> list | error(str)What quillo check says of a program, as a list of { file, line, severity, message } maps, severity being "error" or "warning"; an empty list means the program is fine.
run_script (str, map | null=) -> anyRuns Quillo code written by the program's users (a rule on a form's field, who may see a record) on the server, in a sandbox, and gives its last expression's value, or an error value saying what went wrong.
save_upload (map, str) -> str | error(str)Writes a file the request uploaded to a path under the program's folder, making folders as needed, and gives the path back.
read_upload (map) -> str | error(str)The contents of a file the request uploaded, as text: for a CSV, a JSON file or a script the user sends, read and used without saving it.

Crypto

FunctionWhat it does
crypto.sha256 (str) -> strThe SHA-256 hash of the text, as 64 lower-case hex characters.
crypto.hmac (str, str) -> strThe HMAC-SHA256 of a message under a key, as 64 lower-case hex characters: the key first, the message second.
crypto.token (int=) -> strA random token from the operating system's random source, for session ids, API keys, reset links and secrets: that many random bytes (32 unless given, from 1 to 1,024) written in base64url, so it is safe in a URL, a cookie and a header without encoding.
crypto.hash_password (str) -> strA password's hash for storing, made with Argon2id and a fresh random salt: a string of 97 characters beginning $argon2id$, holding the parameters, the salt and the hash, which crypto.verify_password checks a password against later.
crypto.verify_password (str, str | null) -> boolWhether a password matches a hash made by crypto.hash_password: the password first, the hash second.
crypto.equal (str, str) -> boolWhether two strings are the same, taking the same time whether they differ in the first character or the last.

Channels

FunctionWhat it does
channel.on (str, fn, map | null=) -> nullHandles a channel on the server: written at the top of a program, once for a name, it makes f(msg, peer) the function that gets each message a page sends on that channel.
channel.send (str, map | str, any, map | null=) -> boolSends a value to one page in a channel: the channel's name, the peer (the map the channel's function gets, or its id), the value, and options.
channel.broadcast (str, any, map | null=) -> intSends a value to every page in a channel and gives how many took it.
channel.peers (str) -> listThe ids of the pages in a channel, as a list of twelve-character hex strings, in a fixed order.
channel.open (str, fn, map | null=) -> mapOpens a channel from a page: in a component, channel.open(name, f) joins the channel for as long as the code that called it stands (the component leaving the page closes it).

Media

FunctionWhat it does
image.info (str) -> map | error(str)The size and kind of an image file, from its header alone: { width, height, format, alpha }, with format one of jpeg, png, webp and gif.
image.convert (str, str, map | null=) -> map | error(str)Reads an image (JPEG, PNG, WebP or GIF), crops it, shrinks it and writes it as another file: { crop: { x, y, w, h }, width, format, quality }, giving { width, height } of what was written.
media.rtp (str, map) -> nullMakes a stream that takes a camera's or an encoder's RTP on UDP ports, for pages to play with <quillo-media stream="name">: { video: port, audio: port, host }, one or both tracks, each on a port of its own.
media.close (str) -> boolEnds a stream by name: it stops taking RTP, lets its ports go (waiting up to a second for that, so another stream can take them at once), stops taking frames from pages sending it, and tells the pages watching, whose <quillo-media> turns data-state ended.
media.on (str, map | null=) -> nullLets pages send and watch a stream: after media.on(name, { publish, watch }), a page's <quillo-media publish="name"> sends its camera and microphone (or another MediaStream as its source) to the server, which passes the frames on to every <quillo-media stream="name">, decoding nothing.
media.streams () -> listEvery stream, by name: a list of { name, viewers, video: { frames, fps, kbps, lost }, audio: { frames, fps, kbps, lost } }, sorted by name.

UDP

FunctionWhat it does
udp.listen (int, fn, map | null=) -> nullTakes UDP packets on a port: written at the top of a program, it binds the port when the program starts and calls f with each packet, { text, bytes, from: { host, port }, port, at }.
udp.send (str, int, any, map | null=) -> null | error(str)Sends one UDP packet to a host and port: text as its bytes, a list of byte values (0 to 255) as those bytes, any other value as JSON.
udp.reply (map, any) -> null | error(str)Sends a packet back to where one came from: given the packet map that udp.listen handed to its function, it sends to packet.from from the port the packet came to, packet.port, as most protocols expect the answer.

Jobs and services

FunctionWhat it does
accept_calls (map) -> nullAt the top level of a service, says which calls from other services it takes and how each proves who makes it.
schedule (str | int, fn, map | null=) -> nullRuns a function on the server on a timetable: every so often, given as a duration (seconds, or "30s", "5m", "1h", "1d", "2w", "1y", counted from 1970 in UTC so that "5m" runs at :00, :05, ...), or at the times of a cron line (minute hour day month weekday, in UTC, with *, 1-5, */15 and lists, or @hourly, @daily, @weekly, @monthly, @yearly).
publish (any...) -> nullAnnounces that something changed, by topic name, so that every page whose live data watched the topic loads it again.
watch (any...) -> nullInside a live loader, subscribes the page to a topic, so that publish of that topic runs the loader again.
unwatched (fn) -> anyCalls the function and gives what it gives, without following what it read: the tables, the global variables and the watch calls inside it do not make the running live loader run again.

Browser

FunctionWhat it does
run_after (num, fn) -> nullIn the browser, calls f once, ms milliseconds on, and gives null at once.
page_updated () -> nullIn the browser, in an event handler, waits until the page shows what the handler has set so far, and gives null.
js_has (str) -> boolWhether the page has a feature, by its dotted name, without calling it: true if each part of "navigator.vibrate" is there, false if any is not.
ask (str, map | null=) -> boolAsks a question in a dialog on the page and waits for the answer: true when OK is pressed, false for Cancel, Escape or a click on the backdrop.
notify (str, map | null=) -> nullShows a note on the page (a toast) that goes away by itself after 4 seconds, or after seconds from the options; title adds a heading and tone a class (q-success, q-danger).
js (str, any...) -> anyCalls a function of the page's own scripts, found from the page's globals by its dotted name (js("L.map", el), js("navigator.clipboard.writeText", text)), and gives its result.
js_new (str, any...) -> anyMakes an object of a class the page's scripts define, by its dotted name, with the arguments given to its constructor: js_new("Chart", el, config) is new Chart(el, config).
live (any, any...) -> anyMakes a component's state follow the server: state notes = live(load_notes) calls the server fn now and gives its result, and the browser calls it again, and updates what shows the state, whenever something it read changes (a table it queried, a global it used, a topic it watched), for anyone, not only this page.
parallel (any...) -> listCalls several functions at once and gives their results as a list, in the order the functions were given.
every (num, fn, map | null=) -> nullIn a component's code, calls f every ms milliseconds in the browser, for as long as the code that called it stands: if running { every(100, step) } runs while running is true, starts over when speed or anything else it read changes, and stops when the condition is false or the component leaves the page.
listen (str, fn) -> nullIn a component's code, follows a stream the server sends (a route made with events or stream) for as long as the code that called it stands: f is called with each event's data (parsed as JSON when it is JSON, and the event's name as a second parameter when f declares one), each line of newline-delimited JSON, or each piece of text.
receive (str, fn, map | null=) -> null | error(str)In an event handler of a component, sends a request and calls f with what the answer streams, piece by piece, until it ends: each event's data (parsed as JSON when it is JSON, with the event's name as a second parameter when f declares one), each line of newline-delimited JSON, or each piece of text.
url () -> mapThe address as { path, query, hash }: of the request on the server, and of the address bar in the browser, where what reads it follows it when it changes.
style_with (str | fn) -> nullAt the top level of a program, names a command that every component's and view's style goes through as the program loads, before the styles are scoped: the command reads CSS on its standard input and writes CSS on its standard output.
navigate (str) -> nullGoes to another address from a component's code, as a click on a link would.
waiting (any) -> boolWhether a component's live state is waiting for an answer: true from the moment the arguments of its live(load, ...) change until the new value arrives (and while a page the browser made waits for its first), false otherwise.
Thread
15Useful? Like it, or add to its thread below.

Thread 0 posts

On Function reference: questions, tips, corrections, and code that uses it.

No posts yet. The first one opens the thread.