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
| Function | What it does |
|---|---|
print (any...) -> null | Writes its arguments to stdout as one line, each as text and a space between them, and gives null. |
args () -> list | What followed -- on the command line, as a list of text, for a script: quillo run tool.qwe -- a b gives ["a", "b"]. |
str (any) -> str | The 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=) -> str | A number as a locale writes it: grouped digits, the locale's decimal mark and its minus sign. |
len (str | list | map | html | null) -> int | The 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) -> str | The kind of a value as text: one of null, bool, int, float, dec, str, list, map, fn, html, response and error. |
env (str, any=) -> any | The 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 () -> map | Where the program runs, as a map. |
random () -> float | A float from 0 up to, but not including, 1, different on each call. |
random_int (int, int) -> int | An int from lo to hi, both ends included, different on each call. |
uuid () -> str | A 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
| Function | What it does |
|---|---|
cursor_index (str, int) -> int | The 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) -> str | The text in upper case. |
lower (str) -> str | The text in lower case. |
normalize (str, str | null=) -> str | The text in one Unicode form, so that text which looks the same is the same. |
trim (str) -> str | The 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=) -> list | Cuts text at every occurrence of a separator and gives the pieces as a list of strings. |
join (list | null, str=) -> str | The 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) -> bool | Whether 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) -> bool | Whether the text begins with a prefix. |
ends_with (str, str) -> bool | Whether the text ends with a suffix. |
replace (str, str, str) -> str | The text with every occurrence of one piece replaced by another. |
slice (list | str, int, int=) -> list | str | The 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 | null | The 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) -> str | The text written a number of times in a row. |
Regular expressions
| Function | What it does |
|---|---|
re.valid (any, str | null=) -> bool | Whether a pattern can be run, for one that comes from data or a person. |
re.test (str, str, str | null=) -> bool | Whether a pattern matches anywhere in the text: true or false, nothing about where. |
re.find (str, str, str | null=) -> map | null | The first match of a pattern in the text, or null when there is none. |
re.find_all (str, str, str | null=) -> list | Every 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=) -> str | The text with every match of a pattern replaced. |
re.split (str, str, str | null=) -> list | The text cut at every match of a pattern, as a list of the pieces between the matches. |
Lists
| Function | What it does |
|---|---|
map (list | null, fn) -> list | A new list with the function applied to each item, in order. |
filter (list | null, fn) -> list | The items for which the function gives a true value, in their original order, as a new list. |
find (list | null, fn) -> any | The first item for which the function gives a true value, or null when none does. |
any (list | null, fn) -> bool | true when the function gives a true value for at least one item, else false. |
all (list | null, fn) -> bool | true when the function gives a true value for every item, else false. |
reduce (list | null, any, fn) -> any | Folds the list into one value. |
sum (list | null) -> any | The items added together, starting from 0. |
min (list | null) -> any | The smallest item of a list, or null when the list is empty. |
max (list | null) -> any | The largest item of a list, or null when the list is empty. |
sort (list | null) -> list | The items in ascending order, as a new list. |
sort_by (list | null, fn) -> list | The items in ascending order of a key, as a new list. |
reverse (list | str) -> list | str | A list with its items in the opposite order, or a string with its characters in the opposite order. |
first (list | null) -> any | The first item of a list, or null when the list is empty. |
last (list | null) -> any | The last item of a list, or null when the list is empty. |
push (list | null, any=) -> list | A new list with one item added at the end. |
range (int, int=, int=) -> list | A list of ints. |
enumerate (list | null) -> list | A list of pairs [index, item], one for each item, the index counting from 0. |
unique (list | null) -> list | The list without repeats: the first of each group of equal items, in the order they first appear. |
flatten (list | null) -> list | One list from a list of lists: the items of each inner list, in order, one level deep. |
zip (list | null, list | null) -> list | Pairs 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 | str | The first n items of a list, or the first n characters of a string, as a new value. |
drop (list | str | null, int) -> list | str | The list without its first n items, or the string without its first n characters, as a new value. |
count (list | null, fn=) -> int | How many items there are, or, with a function, how many of them the function says yes to. |
group_by (list | null, fn) -> map | A 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=) -> list | Joins 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
| Function | What it does |
|---|---|
keys (map | null) -> list | The keys of a map, as a list of strings, in the order the entries were added. |
values (map | null) -> list | The values of a map as a list, in the order the entries were added. |
get (map | null, any, any=) -> any | The value under a key, or the default when the key is not in the map; without a default, null. |
has (map | null, any) -> bool | Whether a map has an entry under a key: true or false. |
set (map | list | null, any, any=) -> map | list | A new map with one entry set, or a new list with one item replaced. |
remove (list | map | null, any) -> list | map | A new map without one key, or a new list without every item equal to a value. |
merge (map | null, map | null) -> map | One 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
| Function | What it does |
|---|---|
error (any) -> any | What 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) -> bool | Whether 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) -> any | The value itself when it is not an error value, and a runtime error when it is. |
JSON
| Function | What it does |
|---|---|
json.parse (str) -> any | The 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=) -> str | The value as JSON text, on one line with no spaces. |
Math
| Function | What it does |
|---|---|
abs (num | dec) -> num | dec | The absolute value: the number without its sign. |
round (num | dec, int=, str=) -> num | dec | The number rounded. |
floor (num | dec) -> num | dec | The largest whole number not above the argument: 2.7 gives 2, -2.7 gives -3. |
ceil (num | dec) -> num | dec | The smallest whole number not below the argument: 2.1 gives 3, -2.1 gives -2. |
sqrt (num) -> float | The square root, always a float: sqrt(16) is 4.0. |
pow (num | dec, num) -> num | dec | x to the power y. |
math.sqrt (num) -> float | The square root of a number, as a float, the way Python's math.sqrt gives it. |
math.cbrt (num) -> float | The cube root of a number, as a float, as Python's math.cbrt. |
math.exp (num) -> float | e raised to the power of the number, as a float, as Python's math.exp. |
math.exp2 (num) -> float | 2 raised to the power of the number, as a float, as Python's math.exp2. |
math.expm1 (num) -> float | e to the power of the number, minus one, as a float, as Python's math.expm1. |
math.log (num, num=) -> float | The natural logarithm of a number, as a float, as Python's math.log. |
math.log2 (num) -> float | The logarithm of a number to base 2, as a float, as Python's math.log2. |
math.log10 (num) -> float | The logarithm of a number to base 10, as a float, as Python's math.log10. |
math.log1p (num) -> float | The natural logarithm of one plus the number, as a float, as Python's math.log1p. |
math.pow (num, num) -> float | The first number raised to the power of the second, always as a float, as Python's math.pow. |
math.sin (num) -> float | The sine of an angle in radians, as a float, as Python's math.sin. |
math.cos (num) -> float | The cosine of an angle in radians, as a float, as Python's math.cos. |
math.tan (num) -> float | The tangent of an angle in radians, as a float, as Python's math.tan. |
math.asin (num) -> float | The 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) -> float | The arc cosine: the angle in radians, between 0 and pi, whose cosine is the number, as Python's math.acos. |
math.atan (num) -> float | The 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) -> float | The 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) -> float | The hyperbolic sine of a number, as a float, as Python's math.sinh: (e^x - e^-x) / 2. |
math.cosh (num) -> float | The hyperbolic cosine of a number, as a float, as Python's math.cosh: (e^x + e^-x) / 2. |
math.tanh (num) -> float | The hyperbolic tangent of a number, as a float, as Python's math.tanh: sinh(x) / cosh(x). |
math.asinh (num) -> float | The inverse hyperbolic sine: the number whose math.sinh is the argument, as a float, as Python's math.asinh. |
math.acosh (num) -> float | The 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) -> float | The inverse hyperbolic tangent: the number whose math.tanh is the argument, as a float, as Python's math.atanh. |
math.degrees (num) -> float | An angle in radians as degrees, a float, as Python's math.degrees: the number times 180 / pi. |
math.radians (num) -> float | An angle in degrees as radians, a float, as Python's math.radians: the number times pi / 180. |
math.hypot (num...) -> float | The 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) -> float | The 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) -> int | The largest int that is not above the number, as Python's math.floor. |
math.ceil (num) -> int | The smallest int that is not below the number, as Python's math.ceil. |
math.trunc (num) -> int | The number with its fraction dropped, as an int: rounding toward zero, as Python's math.trunc. |
math.fabs (num) -> float | The absolute value, always as a float, as Python's math.fabs: math.fabs(-3) is 3.0. |
math.copysign (num, num) -> float | The 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) -> float | The 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) -> float | The 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) -> list | The 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) -> list | A 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) -> float | x * 2^e, as a float, as Python's math.ldexp: the inverse of math.frexp. |
math.factorial (int) -> int | n!, the product of the ints from 1 to n, as an int, as Python's math.factorial. |
math.gcd (int | list...) -> int | The greatest common divisor of some ints, as Python's math.gcd: the largest int that divides each of them. |
math.lcm (int | list...) -> int | The least common multiple of some ints, as Python's math.lcm: the smallest positive int that each of them divides. |
math.comb (int, int) -> int | The 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=) -> int | The 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) -> int | The integer square root: the largest int whose square is not above n, as Python's math.isqrt. |
math.isclose (num, num, num=, num=) -> bool | Whether 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) -> bool | Whether a number is neither infinite nor NaN, as Python's math.isfinite. |
math.isinf (num) -> bool | Whether a number is positive or negative infinity, as Python's math.isinf. |
math.isnan (num) -> bool | Whether a float is NaN, "not a number", as Python's math.isnan. |
math.prod (list | null, num=) -> num | The product of a list of numbers, as Python's math.prod, times a start value that is 1 by default. |
math.fsum (list | null) -> float | The 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) -> num | The 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) -> float | The error function, as Python's math.erf: 2 / sqrt(pi) times the integral of exp(-t²) from 0 to x. |
math.erfc (num) -> float | The 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) -> float | The 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) -> float | The 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
| Function | What it does |
|---|---|
stats.mean (list) -> float | The arithmetic mean of a list of numbers, as a float: the sum divided by the count. |
stats.fmean (list, list | null=) -> float | The mean of a list of numbers as a float, optionally weighted. |
stats.geometric_mean (list) -> float | The 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) -> float | The 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) -> num | The middle value of a list of numbers, as Python's statistics.median. |
stats.median_low (list) -> num | The low median of a list of numbers: always one of the data points. |
stats.median_high (list) -> num | The high median of a list of numbers: always one of the data points. |
stats.mode (list) -> any | The most common value in a list, as Python's statistics.mode. |
stats.multimode (list | null) -> list | Every most common value in a list, in the order each was first seen, as Python's statistics.multimode. |
stats.pvariance (list, num | null=) -> float | The 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=) -> float | The 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=) -> float | The population standard deviation of a list of numbers: the square root of stats.pvariance, as Python's statistics.pstdev. |
stats.stdev (list, num | null=) -> float | The sample standard deviation of a list of numbers: the square root of stats.variance, as Python's statistics.stdev. |
stats.quantiles (list, int=, str=) -> list | The 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) -> any | The 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) -> float | The 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=) -> float | Pearson'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=) -> map | The 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) -> map | A 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=) -> map | Counts 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) -> list | Each 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) -> list | Each 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) -> list | The 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=) -> float | The 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=) -> float | The 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=) -> float | The 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
| Function | What it does |
|---|---|
vec.add (list | num, list | num) -> any | Adds 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) -> any | Subtracts 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) -> any | Multiplies 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) -> any | Divides 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) -> any | The 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) -> list | Each item raised to a power. |
vec.dot (list, list) -> num | The dot product of two lists of the same length: the sum of the pairwise products. |
vec.norm (list, num=) -> float | The 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) -> list | The running total: a list where each item is the sum of the input up to and including that position. |
vec.cumprod (list | null) -> list | The running product: a list where each item is the product of the input up to and including that position. |
vec.diff (list | null) -> list | The 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 | null | The position of the smallest number in a list, counting from 0. |
vec.argmax (list | null) -> int | null | The position of the largest number in a list, counting from 0. |
vec.argsort (list | null, bool=) -> list | The 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=) -> list | Each 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) -> list | Each item's absolute value: negatives turned positive, the rest as they are. |
vec.sqrt (list) -> list | The square root of each item, as a list of floats. |
vec.exp (list) -> list | e raised to each item, as a list of floats. |
vec.log (list) -> list | The natural logarithm of each item, as a list of floats. |
vec.round (list, int=) -> list | Each item rounded. |
vec.linspace (num, num, int=, bool=) -> list | n evenly spaced floats from start to stop, both included; n is 50 when left out. |
vec.arange (num, num=, num=) -> list | Numbers from start up to but not including stop, step apart. |
vec.zeros (int) -> list | A list of n ints, all 0. |
vec.ones (int) -> list | A list of n ints, all 1. |
vec.full (int, any) -> list | A list of n copies of a value. |
vec.rolling_mean (list, int) -> list | The moving average: the mean of each run of window neighbouring items, as a list of floats. |
vec.rolling_sum (list, int) -> list | The sum of each run of window neighbouring items, as a list of floats. |
vec.matmul (list, list) -> list | Matrix multiplication. |
vec.transpose (list | null) -> list | Rows 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) -> list | One column out of a list of rows. |
Dates
| Function | What it does |
|---|---|
now () -> int | The 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) -> null | Waits that many milliseconds, then gives null. |
date.today (str | null=) -> str | The calendar date now, as ISO text "YYYY-MM-DD", in UTC. |
date.now (str | null=) -> str | The 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=) -> bool | Whether 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) -> bool | Whether 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) -> str | The date with a year, a month and a day, as ISO text "YYYY-MM-DD". |
date.parts (str) -> map | A date taken apart: a map { year, month, day, weekday } of ints, weekday 1 for Monday to 7 for Sunday. |
date.weekday (str) -> int | The 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) -> bool | Whether 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=) -> int | How many days a month has: 28 to 31. |
date.add_days (str, int) -> str | A date some days later, or earlier with a negative count, as ISO text. |
date.add_months (str, int) -> str | The same day of the month some months on, or back with a negative count, as ISO text. |
date.add_years (str, int) -> str | The same month and day some years on, or back with a negative count, as ISO text. |
date.days_between (str, str) -> int | The 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) -> int | The 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) -> str | The first day of a date's month, as ISO text: "2026-10-27" gives "2026-10-01". |
date.end_of_month (str) -> str | The 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=) -> str | The 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=) -> str | The 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=) -> str | The 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) -> str | A date or a date-time as text, by a pattern or in a locale's style. |
date.ms (str) -> int | A 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=) -> str | Milliseconds since 1970, as now() or date.ms give them, as a date-time to the second: "2026-11-01T14:30:00Z". |
Decimals and money
| Function | What 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) -> int | The 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) -> int | How 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) -> bool | Whether an amount is nothing: true for zero in any currency, false for any other amount, positive or negative. |
money.allocate (map, list | int) -> list | An 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=) -> str | The 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
| Function | What it does |
|---|---|
raw (any) -> html | Marks text as trusted HTML: the result is an html value, which markup writes as it is instead of escaping it. |
escape (any) -> str | The value's text with & < > " ' written as entities (& < > " '), safe to put inside an element or an attribute. |
classes () -> list | The 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=) -> html | Markdown text as HTML: CommonMark with tables, strikethrough and task lists. |
markdown_page (str, map | null=) -> html | Markdown 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=) -> html | Source 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) -> str | The text as it is. |
Translations
| Function | What it does |
|---|---|
translations (str | map, map | null=) -> null | Declares the program's translations, at the top of the program, for t and locale. |
locale_from (fn) -> null | Declares 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 | null | The locale the code runs in, as named in translations: "en", "pt-BR". |
with_locale (str, fn) -> any | Runs 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=) -> str | The key's text in the current locale, from the program's translations. |
Web
| Function | What it does |
|---|---|
url_encode (any) -> str | The value's text written for a URL: every byte but letters, digits and -_.~ becomes %XX. |
Requests and pages
| Function | What it does |
|---|---|
redirect (str, int=) -> response | A 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 | null | next if it is an address on this site, read as a browser reads it, else null. |
respond (int, any=, map | null=) -> response | A response with exactly the status, body and headers given. |
allow_cross_site (str) -> null | Lets the routes under a path take form posts from pages on other sites. |
site_headers (str | map, map=) -> null | Headers 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=) -> response | A response sent as the function makes it. |
events (fn, map | null=) -> response | A response of Server-Sent Events, sent as the function makes them. |
ready (str, fn) -> null | Adds 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=) -> any | Runs the function once for a request, however many times the request is sent. |
Cookies and sessions
| Function | What it does |
|---|---|
set_cookie (str, any=, map | null=) -> null | Adds 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 | null | The 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=) -> null | Tells 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 () -> map | The 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=) -> null | Replaces 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 () -> null | Forgets the visitor's session: the session cookie is removed from the browser with the request's answer, and session() is {} from here on. |
Tenants
| Function | What it does |
|---|---|
tenant () -> str | null | The name of the tenant the code runs for, or null. |
tenant_from (str | fn) -> null | Says how a request's tenant is found, at the top of a program. |
with_tenant (str, fn) -> any | Runs 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) -> any | Makes a tenant's database, migrates it, and runs the function for that tenant, giving what the function gives. |
Database
| Function | What it does |
|---|---|
sql_name (str | list) -> str | A 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) -> str | A 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) -> str | The 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 | null | Says 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) -> any | One 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=) -> any | Runs 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 | null | What 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) -> str | A 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) -> bool | Whether 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
| Function | What 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
| Function | What 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=) -> null | Ends 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=) -> response | A 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=) -> response | A 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=) -> any | Runs 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
| Function | What it does |
|---|---|
crypto.sha256 (str) -> str | The SHA-256 hash of the text, as 64 lower-case hex characters. |
crypto.hmac (str, str) -> str | The HMAC-SHA256 of a message under a key, as 64 lower-case hex characters: the key first, the message second. |
crypto.token (int=) -> str | A 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) -> str | A 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) -> bool | Whether a password matches a hash made by crypto.hash_password: the password first, the hash second. |
crypto.equal (str, str) -> bool | Whether two strings are the same, taking the same time whether they differ in the first character or the last. |
Channels
| Function | What it does |
|---|---|
channel.on (str, fn, map | null=) -> null | Handles 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=) -> bool | Sends 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=) -> int | Sends a value to every page in a channel and gives how many took it. |
channel.peers (str) -> list | The 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=) -> map | Opens 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
| Function | What 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) -> null | Makes 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) -> bool | Ends 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=) -> null | Lets 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 () -> list | Every stream, by name: a list of { name, viewers, video: { frames, fps, kbps, lost }, audio: { frames, fps, kbps, lost } }, sorted by name. |
UDP
| Function | What it does |
|---|---|
udp.listen (int, fn, map | null=) -> null | Takes 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
| Function | What it does |
|---|---|
accept_calls (map) -> null | At 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=) -> null | Runs 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...) -> null | Announces that something changed, by topic name, so that every page whose live data watched the topic loads it again. |
watch (any...) -> null | Inside a live loader, subscribes the page to a topic, so that publish of that topic runs the loader again. |
unwatched (fn) -> any | Calls 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
| Function | What it does |
|---|---|
run_after (num, fn) -> null | In the browser, calls f once, ms milliseconds on, and gives null at once. |
page_updated () -> null | In the browser, in an event handler, waits until the page shows what the handler has set so far, and gives null. |
js_has (str) -> bool | Whether 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=) -> bool | Asks 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=) -> null | Shows 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...) -> any | Calls 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...) -> any | Makes 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...) -> any | Makes 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...) -> list | Calls several functions at once and gives their results as a list, in the order the functions were given. |
every (num, fn, map | null=) -> null | In 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) -> null | In 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 () -> map | The 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) -> null | At 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) -> null | Goes to another address from a component's code, as a click on a link would. |
waiting (any) -> bool | Whether 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
Thread 0 posts
On Function reference: questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.