Trace a value — the period
The most distinctive move in everyday Axioma: end a line with a period and it traces the value — prints it, no function call at all. Axioma's . does two jobs at once — it shows a value and terminates the statement. (A trace shows the value as the language sees it, so a string keeps its quotes; println is the more familiar way to write clean output for a person.)
In the native CLI, stdin, stdout and stderr are read-only names for the corresponding io streams. You can also spell the bare names STDIN, STDOUT and STDERR. write(STDOUT, "hello") prints without a newline. To send a diagnostic to stderr, use println(io.stderr, "Warning") or println("Warning", stream=io.stderr). stream: io.stderr is equivalent. The same destination works with print and printf. read() reads remaining stdin exactly through EOF; write(read()) echoes it without adding a newline. write("notes.txt") prints the filename, and write("notes.txt", text) saves the text to that file. These native standard streams are not exposed by the browser playground.
For keyboard input in the CLI, n: read_int() reads one whole number when you press Enter. Use read_bool() for true or false and read_str() for one word. These are short spellings of read_integer(), read_boolean() and read_string(). For one Unicode character, use read_character() or read_char(). Type a single character such as λ and press Enter. To read a whole line, use readln() or readline(). To check for end of input before reading a line, use eof() or eof(STDIN). It leaves the next byte available, including a newline. On an open pipe or terminal it may wait for data or closure. A failed read raises an Error. For a line of text, split(line) returns its words, skipping runs of whitespace.
The dot terminates a statement, so several can share one line. Here the dots trace 3 and 4. The tutorial displays the final expression’s value separately as ⇒ 7. A program ending in println can show just its printed output.
Bindings — the colon
Axioma binds a name to a value with a colon: name: value — no ceremony. : is an ordinary binding operator (its own token), so even x : 5 — with a space — still binds. (The colon-binding look is one of the ideas Axioma drew from REBOL; the manual's Influences section lists the full lineage.) let and var exist too, but they mean something more specific — fresh declarations, fixed and varying — covered just below.
Start with : to bind a name. You can also write a mathematical assignment such as B = {2, 4, 6}. A later = can warn if the new value changes the type first recorded by :. The optional := aliases = in assignments. Use == to compare values.
Update a number with i += 1 or the standalone statement i++. Use i-- to subtract one. In a multi-name assignment, Axioma evaluates the right-hand values before assigning them to the corresponding names.
Because = declares-or-updates and accepts any case, mathematics reads straight from the page. Need a reserved word, spaces, or punctuation in a name? Guard it with $: $forall (a bare reserved word), $"interest rate" (spaces). $5 is still money; ${...} inside a string is still interpolation.
Float32 and Float64 precision
Convert the same number to two floating-point widths. Here float32 rounds 1.00000001 to 1.0. float64 uses more precision and keeps the sample distinct from 1. Converting the rounded result to Float64 still gives 1, so the comparison gives false. Try 1.5, which both widths can represent exactly.
Fixed names — let, var & const
let name = value declares a fresh, immutable binding — the let of mathematical prose: “let x = 5” fixes x for the rest of the argument, and any later write is refused with a hint. It shadows rather than updates, so an inner let never disturbs an outer name. var is let minus the fixedness — a fresh binding you may keep writing — and it's deliberately the rarer word: : already covers everyday mutation. const NAME = value is stronger again: a program-level commitment, top level only, that refuses reassignment and shadowing. (let and const take = or :=; the retired alias given now points you to these two.)
Writing through a typed reference
ref(10) creates a cell holding 10. The declaration *Integer tells Axioma what the cell can store. Binding other to score gives you a second reference to the same cell. A write through *other changes what you read through *score.
before holds the Integer you read before the write. The two references now both read 15. Try replacing *other += 5 with *other = 20 and predict the three numbers. Then try *other = "five" to see the cell reject a String.
Words, types & introspection
A subtlety worth naming: x: 56 doesn't declare a variable in the C sense — it binds a word. A bare word like x evaluates to its value; :x gets that value; 'x is the word itself, an unevaluated literal of type Word. The word is just a name in a binding table, so it can hold a value of any type.
That last clause — any type — matters: every value has a type. Ask for it with the @ sigil or the type function; the names match the built-in type-concepts, so @5, type(5) and 5 is Integer all agree. And @ reaches past values: aim it at a bare keyword or operator and it reports that token's category — @if is a control_flow_keyword, @+ an arithmetic_operator.
The everyday value types are Integer, Float, String, Boolean, Array, Set, Tuple and Dictionary (a key/value map) — with many more for the reasoning machinery. You can also declare your own closed set of named values, an enum, with enumerates: each member is a real value you can order with .ord and count with len.
An empty Set is {}; an empty Dictionary is {:}. The equivalent constructors dict() and dictionary() remain supported. They print with those distinct spellings. A whole-value assignment can rebind an unannotated name from one type to the other. An entry write such as d["color"] = "green" requires a Dictionary: on a Set it fails with a hint to start with {:}, dict(), or dictionary(). The editor warns when it can establish that the receiver is a Set.
Dictionaries support call-only methods in both runtimes: d.get("points") returns none when absent; d.get("points", 0) supplies a default. A stored none stays none, unlike ??. The default argument evaluates eagerly. d.keys(), d.values(), d.items(), d.has_key(key) and the length aliases are available too. Stored keys and schema-declared fields take precedence, including absent optional fields. Bare d.get remains a key read; local functions do not change this fixed method registry.
Dictionary display and keys(), values() and items() preserve insertion order. Overwriting keeps the key's position; deleting and reinserting appends it. For example, {revenue: 100, expenses: 70} lists revenue first. Walk entries with for key, value in d.items() [ println(key, value) ], or use sort(keys(d)) for a sorted key walk. Equality ignores order, while canonical JSON output still sorts keys.
Dictionary keys are values: 1 and 1.0 share an entry, while "1" and "num:1" are distinct text keys. keys(d) and items(d) return actual key values, including enum members. Equivalent-key overwrites keep the first key representative. JSON export requires String keys; convert non-String keys explicitly.
pairs(d) gives an Array of Pair values in insertion order. Each entry has a key in .first and its value in .second. Try pairs({2: "two", 1: "one"}), or use dict(pairs(d)) to rebuild the Dictionary. On Strings and Arrays, the keys are the indices you would use for lookup.
To visit entries directly, write for key, value := across d { println(key, value) }. For a multiline body, omit the opening brace, start the body on the next line, and close it with end. Leave out , value to visit just the keys. The same header on an Array gives its actual indices, starting at 1 for an ordinary Array; for value in a visits the values. Try the same walk with an Array keyed by day or a Unicode String.
To print just the values, write for _, value in pairs(d) [ println(value) ]. The underscore skips each key. Use for key, value in pairs(d) when you need both.
The language also documents itself. Write doc followed by any word — doc why, doc map — and Axioma prints its built-in reference for that word, in a script or the REPL.
Your own words — aliases
If words are first-class, the natural next step is to add your own. alias new = original gives a keyword, builtin, or user-defined function a second name — so the surface can read the way you think, or skin a small domain language. An alias is a synonym, woven in as the source is read, so define it before you use it.
An alias is additive — it adds a fresh word; it can't shadow a word that already exists, so the new name must be unused (ask for alias repeat = while and Axioma tells you repeat is already taken). And aliases aren't only for keywords — aim one at a builtin, or at a function you wrote. Drop it again with unalias name.
Where : binds now, declare binds lazily — the expression is captured and only computed on first use, so it can even refer to names defined later.
Blocks — the versatile [ ]
Square brackets are the most versatile punctuation in Axioma. At heart, [ ] is a block — a sequence of steps whose value is its last expression. That single idea powers a remarkable range of the language:
- the body of a function —
func(x) [ … ](next lesson); - the body of control flow —
if … then [ … ] else [ … ],while … [ … ],for … in … [ … ]; - a value-block you drop inline to compute something in a few steps (just below);
- a list comprehension —
[ x * x | x <- xs ](Lesson 6); - an array literal, when the brackets hold a comma-separated series of values —
[1, 2, 3]; - and the language & lens forms —
[python | … ],[sql | … ],[model | … ]— that run or translate another notation.
A function body runs its statements in order. In a branch, if true then ["big"] else ["small"] yields the String "big". A comma-separated branch such as if true then [1, 2] else [] yields an Array. In a value binding, v: [7] binds an Array, while the bindings inside the example below make its brackets a block.
An explicit begin … end block also works in value and body positions. begin 7 end yields 7, begin end yields none, and begin [7] end yields the Array [7]. For a conditional branch, write if true then begin 4 end else begin 5 end. Statements, scope and control flow follow the existing block rules; begin is reserved, with $begin as the identifier escape.
A condition can spell “not equal” as !=, ≠ or <>. For example, 3 <> 4 gives true. Used alone, <> is the empty Tag.
That same block is the body of control flow — a loop runs a block per iteration, and an if (an expression) hands back the value of whichever branch it takes:
false and check() skips check(). To run the check, write false `and check(). The same leading backtick works on &&, ∧, or, || and ∨. A closing backtick makes an ordinary infix call: a `and` b calls and(a, b).
Optional: parentheses around the whole condition replace then for one statement on the same line: if (ready) start() else stop(). An ordinary body starting on the next line still needs end; indentation alone never determines the body. Both header and body may be delimited: if (ready) [start() log()] or if (ready) begin start() end. Inside an explicit block, whitespace and semicolons still separate statements. Existing forms without parentheses keep working, including the one-expression rule after then across a newline.
This prints above freezing, always, other. The semicolon ends the inline conditional, so its next statement runs unconditionally. Another same-line statement needs that separator; do not put it before an else belonging to the conditional. An else attaches to the nearest unmatched if; use a block around a nested conditional to attach it to the outer one. A later-line ordinary else body requires end even after an inline first branch. The conditional still returns the selected branch's value and runs only that branch.
Functions
A function is just a value — you bind it with : like anything else, and its body is a [ ] block. Call it with parentheses.
There's an optional named form, the keyword-free equation — how mathematics already writes a definition — and a lightweight lambda … => for short functions. All four spellings build the same thing:
Call a parameter by name with area(h=7, w=6) or area(h: 7, w: 6). Both return 42. Labels may reorder and mix spellings, and leave caller variables of the same names intact. Supply a value after =, and use == for a comparison. This fixed-parameter area example takes labels in the evaluator. The VM supports labeled user-function calls with defaults, collectors or a keyword-only section, as below.
Use a semicolon when a caller must give an argument a name. With scale(x; factor, offset = 0) = x * factor + offset, scale(3, factor=2) returns 6. Passing scale(3, 2) is an error. The same rule applies to lambdas: (; value) => value takes only a labeled argument. Both examples work in the evaluator and with --vm.
A function can collect extra positional values with ...items and extra named values with ..options. For example, fn gather(first, ...items, ..options) [(first, items, options)] then gather(1, 2, color="blue") yields (1, [2], {color: "blue"}). The named collector is last and receives a fresh ordered Dictionary. Both collectors may be empty. Both runtimes can call it as gather(...[1, 2], ...: {color: "blue"}) with the same result.
Functions can call themselves (recursion), and can return other functions that capture their surrounding scope (closures):
Here are three ways to add the same two numbers. Infix puts + between the operands, prefix calls it as a function, and postfix puts it last in a function body’s comma sequence. You can also pass an operator to reduce.
Named results
To split a duration, give the function two named results, minutes and seconds. Each call gets its own result variables. Assign both, then use a bare return to read them in header order. The body calculates seconds first. What tuple will you get for 125 seconds? Try 59 and 60 to see where the minute changes.
Saving a struct method
A struct groups fields and methods under a type name. Here it is the meter whose reading you request. Save meter.reading without parentheses to call it later. The saved method sees the change from 4 to 7. After the type gets a new method that doubles the reading, the saved call still gives 7 and a fresh call gives 14.
Composition — functions over collections
Functions are first-class, so you pass them around. map applies one to every item; filter keeps what matches; reduce folds a collection to a single value.
Keep a combining function and seed together with total: reduce(+, 0), then call total([1, 2, 3]). The two-argument form preserves the direct call: reduce(-, 0)([1, 2, 3]) is the same left fold as reduce(-, 0, [1, 2, 3]), giving −6. Choose foldr(-, 0) explicitly for right grouping, which gives 2. The seed participates even for nonempty input; empty input returns it. foldl, fold_left and fold_right also support reusable calls. See the manual's reusable-fold reference for collection rules.
For an operator, the compact form (+/)(0, [1, 2, 3]) gives 6; total: (+/)(0) builds the same reusable left fold as reduce(+, 0). The seed is required. (-/)(0, [1, 2, 3]) gives −6, while foldr(-, 0)([1, 2, 3]) gives 2. Keep the operator attached to its slash inside parentheses; complete declared custom operators take precedence. See slash reduction for the grammar and compatibility rules.
And because a function is a value, you can compose small ones into a pipeline:
Composing by hand gets noisy. The forward pipe |> threads a value left-to-right into each call, so a chain reads in the order it runs instead of inside-out. The value lands as the call's last argument — matching map/filter/reduce — and an underscore _ hole places it anywhere else.
Its safe sibling |?> short-circuits: if a stage yields an error, none, or om, the remaining stages are skipped and that failure flows out — railway-oriented error handling without nested ifs. A plain value (even 0 or "") is not a failure, so it passes straight through.
A pipe is only as useful as the verbs you can thread through it. Beyond map/filter/reduce, Axioma ships the wider collection vocabulary — and the verbs below take their collection last, so each one drops straight into a |> chain. max_by/min_by return the element with the extreme key (an argmax, not the key itself); sort_by orders by a derived key; tally counts occurrences; detect finds the first match; compact drops none. (Ruby's first-match is find, but that name is reserved here, so the verb is detect.)
Sets, arrays & comprehensions
Sets and comprehensions sit at the centre of Axioma — a great deal of the language reads like the set-builder notation from a maths text, and runs. But it all rests on one distinction worth getting straight first: the difference between an array and a set.
Arrays and sets — order vs uniqueness
An array [ ] is an ordered sequence: it keeps elements in the order you wrote them, keeps duplicates, and you reach one by position — ordinary Axioma arrays index from 1.
A set { } is an unordered collection of unique values: duplicates collapse, there are no positions to index, and because a set has no intrinsic order Axioma may print its members in any order — so never rely on it. You don't ask a set “what's at position 1?”; you ask “is this in it?”.
To build a grid with sizes computed at runtime, use grid = fill((rows, cols), 0). Each row has its own storage, so grid[1][2] = 7 changes one cell. A third length in the tuple adds a third axis. This form works in the interpreter and VM.
Grow an array with scores.push(4, 9, 2). Each argument adds one element. For a descending copy use sort(scores, order="desc"). To reorder the array itself, use scores.sort!(order="desc"). Both sort in ascending order when you omit the direction.
For an imperative Array loop, pets.remove("cat") (also remove(pets, "cat")) removes and returns the first matching value in place. delete(pets, 2) instead removes by index. A missing value errors without changing the Array, so guard repeated removal with membership:
Aliases observe the same Array changing. Both call forms work in the evaluator and VM. remove(path) keeps its separate file/empty-directory meaning.
Optional exercise — an Array keyed by day
In Array[Day] of Integer, the days are the keys and each cell holds a visitor count. visits[Tue] reads Tuesday directly. Filter out the empty days, then walk the remaining keys and counts with across. Wednesday keeps its key. Change Tuesday’s count to 4 and predict where its row will appear.
More about Array keys, dimensions and initialization
Use a.indices() for the keys and a.values() for a one-based copy of the values in the same order. For these Arrays, map retains all keys and filter retains matching keys, including gaps. Generic Array[D] of T function annotations preserve the inferred domain.
Multiple domains use Array[Day, -1..1] of Integer: a[Tue, -1] selects a cell and a[:, 0] selects a column with day keys. These are nested Arrays; loops and map/filter operate one level at a time. indices(a, 2) or a.indices(2) returns column keys when all rows agree, and can recover them from declared inner domains even when no rows remain. Ragged or unknown inner shapes refuse. Incompatible enum redeclarations receive static diagnostics; identical declarations remain valid. Transparent type aliases can name domains; static checking catches provable invalid keys and mismatched domains, while computed keys and filtered membership remain runtime checks.
To initialize every cell, write var grid :: Array[2, 3](0) of Integer. Each row has three zeros and its own storage. fill(grid[1], 7) paints the first row. A literal size fixes the number of one-based slots. For example, var x :: Array[3] of Integer gives indices(x) equal to [1, 2, 3]. A bare declaration such as var squares :: Array[0..9] of Integer allocates ten slots immediately, ready for indexed writes. It does not initialize them to zero: reading an unwritten element errors. len and indices work immediately; explicit = _ still leaves the whole variable uninitialized. Declared index domains use the evaluator. The VM also supports ordinary one-based typed Arrays.
The Manual also covers zero-based keys and Array initialization and arrays with several index domains.
Ranges — generate a sequence
You rarely write a long sequence by hand. A range generates one with the .. operator, inclusive of both ends — and the bracket you choose decides the kind: [1..6] is an ordered Array, while the bare 1..6 is a first-class Range — a lazy, ordered value that knows its own direction and step. Add a step with a third segment ([0..10..2]), count downward by giving a larger start ([5..1]), and range over characters as well as integers. The range(...) function is the same generator in call form.
Ranges are the natural source for everything in this lesson — feed one to a comprehension or a collection function and the sequence streams straight in:
The algebra of sets
Because a set is a mathematical object, the whole algebra is built in: membership ∈ and its negation ∉, union ∪, intersection ∩, difference \, symmetric difference △ (the members in exactly one set — ∆ and ⊖ work too), cardinality with len, and an equality that ignores order. The subset relations come in two strengths: ⊆ / ⊇ allow equality, while ⊂ / ⊃ are proper — strict, and so false when the two sets are equal. If your keyboard lacks the glyphs, most have a word form too — in, union, intersect, difference, symdiff.
Can't type the glyph? Ask Axioma
Since these symbols are hard to type, the language carries a catalog of its own glyphs. symbols() lists them (optionally by category), and glyph(name) fetches one by its Axioma name, its LaTeX name, a Greek letter, an emoji name, or a raw U+… codepoint — so you never need the special key. Each result is a first-class Glyph that prints as the character, compares equal to its string, and carries .name / .meaning / .codepoint. (In the REPL, :symbols prints the table and :doc ∪ explains one.)
Comprehensions — set-builder notation
A comprehension builds a collection by describing it. Read { x | x <- xs, cond } exactly as the maths: “the set of x drawn from xs such that cond.” The part before the bar can transform each element; every comma-separated condition after it must hold — they combine with and. (mod is the word form of %.)
List comprehensions — same notation, ordered result
Swap the braces for brackets and the same notation yields an array — so the result keeps its order and its duplicates. Either form can draw from more than one source at once; several generators produce every combination (a Cartesian product).
Pipe-less form, and dict comprehensions
Axioma's pipe-less for … if … comprehension is the same shape Python uses, when its expressions use syntax and operations shared by the two languages. And a comprehension whose head is a key: value pair builds a hash (a dict) instead of a set.
Query clauses and lazy generators
Use orderby, limit and offset to shape a result. Parentheses build a lazy Generator. With a bare Range as its source, the generator can yield the first five squares without allocating a million input cells.
Textbook ellipsis sets
An arithmetic progression can be written the way a textbook does, with .... A bounded form materializes the set; an open form (no upper bound) is a lazy infinite set — the step is inferred from the leading terms.
Quantifiers — logic that evaluates
The universal ∀ and existential ∃ quantifiers range over a set and evaluate to a truth value. Write them as words…
…or as the symbols mathematicians actually write — the same AST either way:
Logic & rules
Declare a relation, assert some facts, and write rules with the word whenever — path(X, Y) whenever edge(X, Y) reads exactly as English (“there is a path whenever there is an edge” — true of every pair, which is what a rule claims). The word if, Prolog’s :-, and the arrow <== are equivalent spellings. Rules can be recursive — here the engine computes the full transitive closure of a graph, Datalog-style, iterating to a fixpoint.
Rules come in a 2×2: strict (<== / ==>) vs defeasible (<~~ / ~~>), and backward (head <op> body) vs forward (body <op> head). The natural spellings cover the backward column: head whenever body is strict, typically head whenever body (synonym normally; also rule~ head if body / rule/defeasible) is defeasible. Strict rules derive theorems; defeasible ones hold by default and derive conjectures — and the grade is recorded on every conclusion.
Abduction works backwards from an observation. Here abduce lists a premise that could explain Tweety’s flight and labels the rule that supplied it. The result is a candidate explanation; whether Tweety is a bird is a separate question.
The conclusion connective ∴, also spelled therefore, records a proposed inference with logical grounding. Here both comparisons evaluate to true. The displayed strength belongs to the connective. The recursive example above shows how to derive a new fact from a rule. The .qed and .∴ extensions can both hold Axioma source.
Beyond rules, Axioma exposes a whole portfolio of logic engines behind one namespace, [logic/<mode> | …] — SAT, answer-set programming, the chase, SMT, a finite-model finder, a quantified prover, and more. The twist: every answer reports the decidability regime it came from, so you always know whether a result is a genuine decision, a bounded search, or a sound-but-incomplete heuristic. A direct chase of these existential rules would keep inventing parents. Here [logic/answer] still decides the query completely, by rewriting it instead of building the infinite model.
In the native CLI, [logic/smt | x + 0 == x] uses Z3 for arithmetic. Install Z3 on PATH or configure a compatible solver with AXIOMA_SMT. The namespace also includes logic/valid and the quantified prover logic/prove. The solver’s regime tells you which conclusions its procedure supports. The browser example above uses query rewriting.
Committing and rolling back facts
The first with transaction block registers Ada and commits when the block finishes. The second registers Bo, then division by zero raises an error. The error leaves the block before try catches it, so the second registration rolls back. Predict whose name the final query will find.
Replace 1 / 0 with true to commit both registrations. Here a commit keeps facts for the rest of this browser run. The Manual explains the scope of rollback and how native tools share canonical definitions.
Checking a proposition in isolation
Does this attendance list establish that Bo registered? Download the JSON request and run the command below in its directory with the native Axioma CLI. The worker starts fresh. It checks the target against the relation definition and facts in the file’s snapshot. You get the same answer even if you just committed Bo’s registration in the browser.
axioma --proposition-worker < attendance.json
Read outcome in the JSON reply. It says unresolved because the snapshot supplies neither a registration nor a denial for Bo. In target, change "Bo" to "Ada" and rerun the command. Now outcome is entailed and the witness names the supplied fact ada-registration.
Both replies report effects: [] and external_evidence: "not_checked". The worker checks what the snapshot supports and leaves the KB untouched. An MCP client can submit the same JSON to proposition_check.
Concepts & the copula is
A concept starts as a class but is more than one — it can also carry actions, a defining boundary, and an epistemic grounding (the overview goes deeper). The everyday parts: declare fields with has (several at once), make an instance with the indefinite article a / an, and classify with Russell's copula is — which Axioma keeps precise: membership (∈) for an instance, class-inclusion (⊆) between two concepts.
Subclass with extends, and give a concept behaviour with an action — a method whose body sees the receiving instance as it. Actions are inherited down the extends chain and can be overridden.
Beyond true and false
Belnap’s ⊤⊥ᵇ records support for both a claim and its denial. Kleene’s ?ᵏ represents missing information. Combine each with true to see which value survives.
Belnap's four values form a bilattice — ordered two ways at once: by truth (false → true) and by information (neither → both). The conjunction below preserves conflicting evidence. Belnap’s branching rule designates ⊤⊥ᵇ, and a match can handle that value explicitly. Type the glyphs as ASCII digraphs: `belboth, `glut, `gap.
Truth is only one axis. A single fact carries orthogonal axes at once — its Belnap truth, its epistemic grounding (Lesson 8), and its kind (empirical, logical, …) — each set and queried independently.
Refinements — one word, adapted
A refinement is a /word suffix that adapts a keyword or operator instead of inventing a new one. On the copula, bare is tests class membership (∈), while is/same tests identity (= — the very same entity, canonically written === or same?(a, b)).
The same /word dialect tunes a fact's lifecycle: with native persistence enabled, /persist requests storage in the knowledge base. /transient keeps it in the session. This example inspects its grounding in memory. And it composes with epistemic grade — axiom/transient is still graded axiom, just not saved to disk.
Code is data — metaprogramming
Axioma is homoiconic: programs are data you can build, inspect and run. parse turns a string into an AST, quote captures code unevaluated, do runs an AST, and a macro rewrites code before it executes.
The *form family renders any expression for inspection — fullform as a Mathematica-style string, treeform as a tree, and tableform a relation's extent as a table.
A binary relation is also a graph: graphform renders it as ASCII, as a Sowa conceptual graph, or as Graphviz DOT you can paste into any renderer.
Meaning & natural language
Axioma can model meaning directly. A cognitive word carries Wierzbicka's NSM semantic primes and a Schank Conceptual-Dependency act — the building blocks linguists use to decompose meaning.
Relations can name the role of each argument. Here the first place identifies the giver and the third identifies the recipient. A query can select either. For other language features, see offline translation, native imports and provider-backed symbolization.
Pattern matching
ML- and Rust-style match … with tries each arm top-to-bottom. A when clause adds a guard; _ catches everything else. match is an expression — it yields the value of the first arm that fits.
When no arm matches and there is no catch-all, the expression yields none. A fault while evaluating a selected arm still propagates.
Errors are values
Axioma has no exceptions and no stack unwinding. try(expr) runs the expression and hands back any fault as an ordinary, inspectable value — which auto-classifies into a concept like DivByZero, TypeError or IndexError, so you can branch on it with the same is copula you use everywhere else. To supply a default, write try(0^-1, 42). This gives 42. The default runs only on an Error. Use try((a, b)) for a two-element Tuple.
otherwise is the railway operator: if the left side faults, take the right instead.
Strings & text
${…} interpolates any expression straight into a string — names, arithmetic, calls.
\u{…} escapes reach the entire Unicode range — handy for the mathematical symbols Axioma reads natively — and codepoint(x) reads the number for a single Unicode scalar. Use character(n) to turn that number back into a Character.
Converting between Rune, Character and String
Single quotes make 'λ' a Character. rune converts it to its numeric code point, 955. char turns that code point back into a Character. In the final tuple, string(r) gives the decimal digits "955" and string(ch) gives the letter "λ". Try replacing the quoted λ with 🙂.
Walking a String by code point
Use across with a String to get a one-based position and a Rune at each step. Each row shows the position, the numerical code point, its glyph from char(r), and the result of the type check r is Rune. Both λ and 🙂 take several bytes in UTF-8. Predict the position of A, then run the example.
Stacks & loops
Axioma has a first-class Stack that reads like prose: construct it with a Stack, mutate it with message verbs (push, pop, dup, swap), and read it with the possessive ('s top, 's depth). The function-call forms (push(s, x), pop(s)…) still work too.
And when a loop is the clearest tool, the examples below use while, a counted repeat, and foreach.
For one statement on the same line, delimit the whole header: for (i in 1..3) println(i), while (n < 3) n := n+1, or repeat (3) println("tick"). The aliases foreach and loop follow the same rule. A body starting on the next line still requires end; indentation alone never extends a loop. Both header spellings also accept [...] or begin ... end.
for (i in 1..3) println(i); println("done") prints done once, outside the loop. Whitespace alone before that second statement is an error. Put both statements inside an explicit body to repeat both. Destructuring parentheses are separate: for (x,y) in pairs [...] keeps its meaning; the inline form is for ((x,y) in pairs) println(x+y). Headerless and pre/post-test repeat forms keep their explicit bodies.
A three-clause loop
Read the header from left to right. i := 1 sets the initial counter, i <= 3 is tested before each trip, and i++ runs after the body. The two output columns show the counter and the running total. Try i += 2 as the update and predict the final total.
Choosing an action with switch
A statement switch tests its subject against the case labels in order. In this example the first match prints the opening hours and finishes the switch. Saturday and Sunday share a case. Monday has its own, and default handles the remaining days. Change "Sat" to "Sun" in the first call and run it again.
Doctests — examples that test themselves
An example in your documentation can also be a test, so it can't quietly rot. In a plain script a # → trailing a line is just a comment, so Run below simply traces values:
Run the same lines as a doctest and each # → becomes a checked assertion instead of a comment — the short #> and the ASCII # -> are equal spellings of the marker (spacing after # is ignored), and # raises: substr asserts that a line errors with a message containing substr. Anything else is setup, and lines in one run share scope. A file with no fence runs whole; to keep checks to a region, embed them in a fenced block opening with ```axioma doctest, inside a /**md … */ literate block or a .md file:
axioma -t path.ax(--test; the older--docteststill works) checks the file — or every fence-bearing file in a directory — and reportsok:/not ok:, exiting non-zero if any check fails or nothing was checked.axioma -t -e '2 * 4 #> 8'checks a one-liner.- In the Playground, the ✓ Doctest button checks the current editor text. It checks the whole example above because it has no fences.
The full rules are in the Manual § 24; for assertions inside ordinary scripts, see the expect builtin.
Ask the language — the self-describing runtime
The reference lives in the runtime, not just in the manual. doc word documents a name (try doc Integer for a full type card), describe(x) inspects a value, apropos("term") searches every name and documentation string, and functions(Integer) lists what you can do with a type:
For a structured, read-only snapshot, start with reflect(x): explore .type, .preview, .binding, .function, and .representation. A bare name includes its binding metadata; an expression runs once and has no binding. Strings stay Strings, quoted code stays inert, and saved snapshots do not follow later changes. Call reflect directly; wrappers inspect their own parameters. Metadata sequences are immutable Tuples. The evaluator and VM support it within their supported execution forms; the VM still refuses deferred/lazy forms and synthetic recursive self-binding inspection. Textbook Appendix E contains an optional lesson with exercises.
Code is data all the way down: source(f) reconstructs a function's definition as a re-evaluable String, and ast("src") parses a runtime string into an AST value without executing it (eval runs either):
The full vocabulary — builtins(), concepts(), bindings(), keywords(), methods, arity, parameters, and the CLI-only compile(src) — is in Manual § 25.
Native Go & Python
These two programs use the native Axioma interpreter. Download each file and run the command shown from its directory. The Go package used here ships with the CLI. The Python exercise also needs Python 3 on your path as python3, or an interpreter selected with AXIOMA_PYTHON. It uses the standard library and Axioma’s default Python worker.
Reading a trailing Go error
Go’s strconv.ParseUint returns a number and an error. Binding both results gives you 42 and none on success. The largest unsigned 8-bit value is 255. When you ask for 300, Go returns 255 together with a range error. In an ordinary expression that error propagates, so the last call takes the otherwise branch.
import "ffi:go:strconv"
n, err = strconv.ParseUint("42", 10, 8)
println(n, err)
text: "300"
n, err = strconv.ParseUint(text, 10, 8)
println(n, error?(err))
println(strconv.ParseUint(text, 10, 8) otherwise "out of range")
Run axioma go-errors.ax. The three lines read 42 none, 255 true and out of range. Change "300" to "200" and predict the last two lines.
Passing Go results to Python
Use Go’s Atoi to parse four readings. Pass the resulting Axioma Array to Python’s statistics.median, which receives a Python list. The two middle readings are 14 and 20. Their average comes back to Axioma as the Float 17.0.
import "ffi:go:strconv"
import "ffi:python:statistics" as stats
readings: map(s => strconv.Atoi(s), ["10", "14", "20", "50"])
println(readings)
println(stats.median(readings))
Run axioma readings.ax. Change the third reading to "30" and run it again. The printed Array shows exactly which values went to Python.
That's the core.
You've met bindings, blocks, functions, sets, logic, concepts, many-valued truth, refinements, metaprogramming and natural-language meaning — enough to read most Axioma. Take a browser example into the full playground and keep going.
Continue with exercises and worked solutions in the Axioma textbook.