core
the basics: kinds of value, printing, converting between types, reading values from text, and help
Permissions: stdin
The basics every other module builds on: kinds of value, converting between them, printing, and help. Every value has a type, and nil means no value. Numbers come in three kinds. An int is a whole number of any size. A frac is an exact fraction, which is what dividing ints or typing a decimal like 0.1 gives you. A float is an approximate decimal, which is what roots and logs give you.
writing
Section titled “writing”to followed by a type name converts to that type: "42" to int, 7/2 to float, "abc" to list.
good to know
Section titled “good to know”Fracs show as decimals unless you ask for to frac.
Tags: conversion, parsing
printprint the values on one line, separated by spacespageprint like print, but output too long for the terminal opens in a scrollable viewerwarnprint a warning to stderr, dimmed in a terminal, and carry onfailstop with an error messageassertstop with an error unless the condition is trueeditopen a full-screen editor to type or paste text into, starting from texttypethe name of a value’s type, like “int” or “quantity”strconvert to a stringintconvert to an integer, dropping any fractional partfloatconvert to a floatfracshow a number as a fraction, like 7/2, or as text rounded to the nearest 1/den, like “2 11/16 in”boolwhether a value counts as true in a test: everything does except nil and false, even 0 and “”listconvert to a list: a string’s characters, a map’s [key, value] pairs, a set’s items, a table’s rows as maps, or a copy of a listdesugarshow what shell-style command lines mean: src with each one rewritten as the ordinary zil call it runsparsedhow src groups, with each operation that is an operand of another in parenthesesprettya value as easy-to-read textparseread a value written in zil syntax from text: a number, string, list, map or quantityhelphelp as textsearchfunctions whose name or description mentions a word, as textdocattach a description to your own function, shown by helptipa random example to try, from help(“examples”) and help(“advanced”)
1# nil: no value2nil3# bool: true or false4true5# int: a whole number, any size60xff7# float: an approximate decimal81.5e315009# frac: an exact fraction107/2 to frac7/211# fn: a function12|x| x * 2<fn>syntax
Section titled “syntax”1# input holds everything piped into a script, as one string2# to str, to int, to float, to frac, to bool or to list3"42" to int42pretty
Section titled “pretty”1# long: separators, every decimal kept2pretty(1234567.891)"1,234,567.891"3# short: 3 digits and K, M, B or T4pretty(1234567, "short")"1.23M"Functions
Section titled “Functions”print(*xs: any) -> nil
print the values on one line, separated by spaces
1print("total:", 5 km)See also str
page(*xs: any) -> nil
print like print, but output too long for the terminal opens in a scrollable viewer
Arrow keys or the mouse wheel scroll, / searches and q quits
1help("math") |> page2(1..200).map(|n| n ** 2).join("\n") |> pagewarn(msg: str) -> nil
print a warning to stderr, dimmed in a terminal, and carry on
1warn("rates are stale")fail(msg: str) -> nil
stop with an error message
1fail("no such planet")assert
Section titled “assert”assert(cond: any, msg: str = “assertion failed”) -> nil
stop with an error unless the condition is true
1assert(1 + 1 == 2)2assert(2 > 3, "two is not bigger")edit(text: str = “”) -> str
open a full-screen editor to type or paste text into, starting from text
Ctrl-S finishes and returns the text, and Esc cancels, which is an error
1edit().lines.len2edit(paste()).uppertype(v: any) -> str
the name of a value’s type, like “int” or “quantity”
1type(5 km)"quantity"2type("hi")"str"3type([1])"list"str(v: any) -> str
convert to a string
Floats keep every digit, unlike the rounded way they’re shown
1str(1/3)"0.3333333333333333"2str(5 km)"5 km"int(v: num|str) -> int / int(s: str, base: int) -> int
convert to an integer, dropping any fractional part
Strings are read as numbers, in the given base if there is one, or by their prefix like 0x
1int(3.9)32"ff".int(16)0xff3"0b101".int0b101float(v: num|quantity|str) -> float
convert to a float
A quantity loses its unit
1float("2.5")2.52float(5 km)5frac(v: num|quantity, den?: int) -> frac|int|str
show a number as a fraction, like 7/2, or as text rounded to the nearest 1/den, like “2 11/16 in”
A float becomes the simplest fraction that’s within 1e-12 of it. With den the result is mixed text and keeps units
17/2 to frac7/221/3 + 1/6 to frac1/230.75.frac3/442.7 in to frac(16)"2 11/16 in"See also float, mixed_frac
bool(v: any) -> bool
whether a value counts as true in a test: everything does except nil and false, even 0 and “”
1bool(0)true2nil to boolfalseSee also str
list(v: str|list|map|set|table) -> list
convert to a list: a string’s characters, a map’s [key, value] pairs, a set’s items, a table’s rows as maps, or a copy of a list
1list("abc")["a", "b", "c"]2"abc" to list["a", "b", "c"]3{a: 1, b: 2}.list[["a", 1], ["b", 2]]desugar
Section titled “desugar”desugar(src: str) -> str
show what shell-style command lines mean: src with each one rewritten as the ordinary zil call it runs
help(“shell”) explains command lines
1desugar("grep -iv err")"grep(\"err\", ignore_case: true, invert: true)"2desugar("diff a.txt b.txt")"diff(read_file(\"a.txt\"), read_file(\"b.txt\"))"parsed
Section titled “parsed”parsed(src: str) -> str
how src groups, with each operation that is an operand of another in parentheses
Shows how units and operators bind without running anything
1parsed("5 m/2 s")"(5 m) / (2 s)"2parsed("1 + 2 * 3 ** 2")"1 + (2 * (3 ** 2))"pretty
Section titled “pretty”pretty(v: any, style: str = “long”) -> str
a value as easy-to-read text
The “long” style spells things out, and “short” keeps it compact. The help page for each type shows how it looks
1pretty(1234567)"1,234,567"2pretty(1234567, "short")"1.23M"See also str, commas, simplify, parts, format
parse(s: str) -> any
read a value written in zil syntax from text: a number, string, list, map or quantity
It never runs code, so it’s safe on untrusted text
1"[1, 2.5, 0xff]".parse[1, 2.5, 0xff]2"5 km".parse to m5000 mTags: parsing
help(topic?: any) -> str
help as text
The topic can be a function, a module (“trig” or “math.trig”), a unit, or any value to list the functions for its type
1help(upper)2help("math.trig")3help(today)4help("text") |> grep("case")search
Section titled “search”search(word: str) -> str
functions whose name or description mentions a word, as text
Unlike help, it searches even when the word names a function or page: search str lists the functions about strings
1search("sorting") |> grep("desc")As a command:
search str# → search("str")See also help
doc(f: fn, desc: str, examples?: list, tags?: list) -> nil
attach a description to your own function, shown by help
It applies to every overload of f’s name. Examples are strings of code that help runs, and tags are plain labels.
1area(r) = 3.14 * r^2; doc(area, "area of a circle", examples: ["area(2)"])See also help
tip() -> str
a random example to try, from help(“examples”) and help(“advanced”)
1tip()See also help
More examples
Section titled “More examples”1# what type a value is2type(5 km)"quantity"3# parse values from text4parse("[1, 2, 5 km]")[1, 2, 5 km]Example results generated on 2026-11-04. Ones using now, today or randomness will differ when you run them.