Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

core

values, printing, type conversions, parsing, help

Example results generated on 2026-10-08. Ones using now, today or randomness will differ when you run them: press Run on any example to run it in your browser, after editing it if you like.

types

# nil
nil
# bool
true
# int
0xff
# float
1.5e3
# → 1500
# frac
7/2 to frac
# → 7/2
# fn
|x| x * 2
# → <fn>

names

# input  (stdin as a string): input.lines.len

conversions

# to str int float frac bool list
"42" to int
# → 42

pretty

# long: thousands separators, decimals kept
pretty(1234567.891)
# → "1,234,567.891"
# short: K M B T, 3 significant figures
pretty(1234567, "short")
# → "1.23M"

Functions

functiondescription
print(a?: any, ...)print values separated by spaces
page(a?: any, ...)print like print, but long output opens a scrollable pager (arrows, wheel, / to search, q to quit) when shown on a terminal
type(v: any)the type name of a value
str(v: any)convert to a string (full float precision)
int(v: num|str) / int(s: str, base: int)convert to an integer, parsing strings in an optional base
float(v: num|quantity|str)convert to a float; drops a quantity’s unit
frac(v: num)show as a fraction; floats become the simplest fraction within 1e-12
bool(v: any)truthiness: false only for nil and false
list(v: str|list|map|set|table)convert to a list: characters, a copy, [key, value] pairs, a set’s items, or a table’s rows as maps
pretty(v: any) / pretty(v: any, style: str)human-readable text; style is “long” (default) or “short”; help(int), help(date), help(set), help(table) and the quantity, uncertain, list and map module pages show each type’s rules
parse(s: str)read a zil literal (number, string, list, map, quantity); never runs code
help(topic?: any)this help, as text; topic is a function, module (“trig” or “math.trig”), unit, or any value to list functions for its type
tip()a random one-liner or recipe to try, from help(“examples”) and help(“advanced”)

print

print(a?: any, ...): print values separated by spaces

print("total:", 5 km)

See also: str

page

page(a?: any, ...): print like print, but long output opens a scrollable pager (arrows, wheel, / to search, q to quit) when shown on a terminal

help("math") |> page
(1..200).map(|n| n ** 2).join("\n") |> page

See also: print, help

type

type(v: any): the type name of a value

type(5 km)
# → "quantity"
type("hi")
# → "str"
type([1])
# → "list"

See also: str, int, float

str

str(v: any): convert to a string (full float precision)

str(1/3)
# → "0.3333333333333333"
str(5 km)
# → "5 km"

See also: int, float

int

int(v: num|str) / int(s: str, base: int): convert to an integer, parsing strings in an optional base

int(3.9)
# → 3
"ff".int(16)
# → 0xff
"0b101".int
# → 0b101

See also: float, str

float

float(v: num|quantity|str): convert to a float; drops a quantity’s unit

float("2.5")
# → 2.5
float(5 km)
# → 5

See also: int, str

frac

frac(v: num): show as a fraction; floats become the simplest fraction within 1e-12

7/2 to frac
# → 7/2
1/3 + 1/6 to frac
# → 1/2
0.75.frac
# → 3/4

See also: float

bool

bool(v: any): truthiness: false only for nil and false

bool(0)
# → true
nil to bool
# → false

See also: str

list

list(v: str|list|map|set|table): convert to a list: characters, a copy, [key, value] pairs, a set’s items, or a table’s rows as maps

list("abc")
# → ["a", "b", "c"]
"abc" to list
# → ["a", "b", "c"]
{a: 1, b: 2}.list
# → [["a", 1], ["b", 2]]

See also: chars, parse

pretty

pretty(v: any) / pretty(v: any, style: str): human-readable text; style is “long” (default) or “short”; help(int), help(date), help(set), help(table) and the quantity, uncertain, list and map module pages show each type’s rules

pretty(1234567)
# → "1,234,567"
pretty(1234567, "short")
# → "1.23M"

See also: str, commas, simplify, parts, format

parse

parse(s: str): read a zil literal (number, string, list, map, quantity); never runs code

"[1, 2.5, 0xff]".parse
# → [1, 2.5, 0xff]
"5 km".parse to m
# → 5000 m

See also: str, nums

help

help(topic?: any): this help, as text; topic is a function, module (“trig” or “math.trig”), unit, or any value to list functions for its type

help(upper)
help("math.trig")
help(today)
help("text") |> grep("case")

tip

tip(): a random one-liner or recipe to try, from help(“examples”) and help(“advanced”)

tip()

See also: help

More examples

core

# type of anything
type(5 km)
# → "quantity"
# parse values from text
parse("[1, 2, 5 km]")
# → [1, 2, 5 km]