A document of lines
A smoot document is a list of lines. Each line is either a name for a value or a bare expression, and its answer appears beside it.
price = 50
tax = price * 8%
price + taxLines can come in any order. The notepad works out what depends on what and evaluates the dependencies first, like a spreadsheet or the back of an envelope.
total = price + tax
price = 100
tax = 15A name that refers to itself, directly or through other names, is an error: “refers to itself” for one line, “these lines depend on each other” for a loop through several.
Comments, headings, and notes
Section titled “Comments, headings, and notes”A line starting with # is a comment. The forms // and -- work too. A line
starting with ## is a heading. /* … */ comments out a span.
## Groceries
# the weekly shop
bread = 1.20 // per loaf
milk = 0.95 * 2 -- two pints
bread + milkA line of plain English with no defined names in it is treated as a note and
ignored. A note that mentions a defined name, including a unit name, is read
as an expression and fails. When in doubt, start the line with #.
This line is a note and shows nothing.
# Safe: a comment can say anything, even 5 m of rope.A name can be a whole phrase. Words with spaces are fine; smoot takes the longest name it knows.
coffees per week = 5
price per coffee = 4.50
weekly coffee spend = coffees per week * price per coffeeNames start with a letter, an underscore, or a degree or prime sign (°,
′, ″), and use letters, digits, and underscores. Any alphabet’s letters
count (π, θ, café). The signs only lead a name: °C is a name, a bare
° is the degree, and 51°30′26″ is an angle. Other symbols such as ² and
× are not letters. The prelude binds π and τ beside pi and tau.
let marks a name as private. In a single document that changes nothing;
it matters only when a document is imported by another (see
Imports).
let deposit = 500
deposit * 2Do not name a value after a unit you also use. A name shadows the unit
everywhere, so hours = 12.5 hours reads as hours = 12.5 * hours, and the
line reports that “hours” refers to itself. Write shift = 12.5 hours.
Declaring the same name twice is a warning; the later declaration wins.
Totals
Section titled “Totals”total adds up the lines since the previous aggregate line (any of the
words below ends a group), back to the top of the document for the first one. It adds the lines that are the same kind
as the line just above it: under a list of prices, a stray weight is
skipped. A plain 0 counts as a zero of whatever kind the others are.
Name a total (subtotal = total) to use it later.
rent = 1350
food = 420
subtotal = total
travel = 85
totaltotal has companions that read the same lines: sum (the same as
total), product, sum of squares, average (also mean and
arithmetic mean), harmonic mean, geometric mean, count, median,
minimum and maximum. They use the same units and the same kind rule.
Aggregate lines that follow one another read the same lines, so a second one does not read the first one’s answer. A note between them does not break the run; any other line starts a new group.
a = £10
b = £20
total
average
maximumA line of three dashes (---) ends a group: the aggregate below it reads
only the lines after it. The ledger draws the rule beside the dashes when an
aggregate uses it, and nothing beside one that no aggregate reads.
rent = £800
food = £250
---
a = £10
b = £20
totalOne line can use several words (maximum / total). If you name something
total or average, the word means your value instead.