The Literally language.
If your invoice calls something the “Deposit Paid”, you can call it Deposit Paid in the formula too. Spaces belong to the name. Someone checking the bill can read the rule in the same terms as the bill itself.
From a name to a sentence
Write a definition on its own line. Capitalise each word in a name and use the same spelling wherever you refer to it. Agreed Fee works as written, without quotes, underscores or camel case.
Agreed Fee = £2,400.00
Deposit Paid = £600.00
Balance Due = Agreed Fee - Deposit Paid
Your remaining balance is **=Balance Due**.
Your remaining balance is £1,800.00.
The definitions stay in the source. A leading = brings the value into the sentence, and the Markdown asterisks make it bold. Change the deposit to £800 and the sentence shows £1,600.00. In the editor, Show formulas reveals the working in place.
You can put arithmetic directly in a sentence, too. In Each instalment is =(Balance Due / 3). the parentheses mark where the calculation ends and the prose resumes.
You can keep the reasoning visible in a formula. If a day includes two hours of preparation and three hours on site, write Hours = Days * (2 + 3). Literally adds the two allowances once and uses the total whenever Days changes. Open the formula to edit either allowance.
To evaluate each step as written whenever the formula runs, press Shift+Enter while editing it. The choice travels with the document as Hours = (as written: Days * (2 + 3)).
Give each result a name
A quote has two prices. Write the calculation once and give both prices names you can use throughout the document.
Mid Price = £100.00
Half Spread = £2.00
Bid, Ask = [Mid Price - Half Spread, Mid Price + Half Spread]
We bid =Bid and ask =Ask.
The reader sees “We bid £98.00 and ask £102.00.” The square brackets give the prices in order. A function or either branch of an if can return the same pair.
When the result has named fields, Literally matches the names. For example, High, Low = {"Low": 4, "High": 9} gives High the value 9. Each name must occur once, and the number of results must match.
How to write a value
- Numbers
12is a whole number.12.50is an exact decimal that remembers its two decimal places.25%represents a quarter. Scientific notation works too.2e3means 2 × 10³, or 2,000. Lowercaseeis reserved. Useexp(1)for Euler’s number.- Large amounts
- Attach the suffix directly to the number. Write
kfor thousand,m,mm,mnormiofor million,b,bb,bnorbiofor billion, andtortnfor trillion. Capital and lowercase letters work equally well. For example,£2.5Mmeans £2,500,000 and1.2bn CADmeans 1.2 billion Canadian dollars. - Multiplying by a letter
- Suppose you define
b = 7. In a sentence,=2bshows 2,000,000,000 and=2 * bshows 14. While editing=2b, click Multiply by b or press Alt+Enter to use the variable. The editor offers the same choice fork,mandtwhen you have defined the letter with that spelling. Longer suffixes such as2mmand2bnalways give the scaled amount. - Money
- Write
520 CADorCAD 520for 520 Canadian dollars. Leave a space between the amount and its three-letter currency code. You can also write£1,200.00,€45.00or$19.95for sterling, euros or US dollars.500k CADmeans half a million Canadian dollars. Amounts being added must share a currency. - Dates
22 November 2026,22 nov 2026anddate("2026-11-22")mean the same day.Invoice Date + 30gives a date thirty days later.- Text and decisions
"Awaiting payment"is text.trueandfalseare the two results of a test.nullexpresses an empty value.- Lists and records
[7, 14, 30]holds three items in order.[7, 14, 30][1]reads the first, 7. A record stores named fields, as in{"Client": "Atelier", "Days": 14}.
A written form can travel with a value. Balance Due as "0dp" shows whole pounds while keeping the amount available at its original precision. Balance Due / 3 to nearest 2 places rounds the instalment itself for later calculations.
Operators and choices
- Arithmetic
+,-,*and/add, subtract, multiply and divide. Multiplication and division come before addition and subtraction. Parentheses group a calculation. With two text values,+joins them.- Powers and remainders
2 ^ 3and2 ** 3both give 8.17 mod 5gives 2, and17 \ 5gives the whole-number quotient, 3.- Comparisons
Balance Due > £0.00tests whether anything remains to pay. Use==for equality,!=or<>for inequality, and<,<=,>or>=to compare order. Within an expression, a single=also tests equality.- Checking a kind or origin
- The preferred form is
value is_a Base. Use a named table or element to check what a value is based on. For a built-in type, quote its name, as in£75.00 is_a "money". The older function spellingis_a(value, Base)still works. - Logic
andrequires both tests to pass.notreverses a test. In a scalar expression,orandxormean exactly one test passes. Use||orand_orfor either or both. In a table filter,orincludes a row when either or both conditions match.- Functions and rounding
sum([7, 14, 30])gives 51.1.231 up to 2 dpgives 1.24. Usedown toto round down andsffor significant figures.
More operators for numbers and collections
25% 80takes a percentage of an amount, giving 20.5!takes a factorial, giving 120.~tests approximate numeric equality.<<and>>shift an integer’s bits left or right.[1, 3...9]builds the sequence 1, 3, 5, 7, 9.1 : [8, 9, 10]selects the first item, 8.- For a record named
Order,Order.Client,Order["Client"]andOrder -> "Client"all read its Client field.
You can choose the wording as well as the amount. Write the result first, followed by the condition that selects it.
Payment Status = "Paid in full" if Balance Due == £0.00 else "Balance outstanding"
Payment status: =Payment Status.
For a choice between whole Markdown passages, enclose each alternative in three straight apostrophes. The supper proposal uses this to choose its approval paragraph. See the source beside the two outcomes.
Each alternative keeps its own formatting. In the editor, select words in a passage and apply bold, italic, underline or strikethrough. The editor writes the markup into that alternative. For example, <u>approval required</u> underlines those words and ~~draft~~ strikes through draft.
First and second derivatives
Share Delta = derivative of Position Value with respect to Share Price
Share Gamma = second derivative of Position Value with respect to Share Price
Delta tells you how quickly the position value changes as the share price moves. Gamma tells you how quickly delta changes. Use named numbers for the value and the input. Display =Share Delta in a sentence or table cell to show its current value. Explore delta, gamma and vega in the Black–Scholes example.
To draw the curve, write Delta Curve = plot_series(Share Delta, Spot, 33, 53, 41) or choose Plot a formula over a range when inserting a chart. This samples delta at 41 share prices from £33 to £53, holding the other inputs fixed. The example compares the gain estimated from the starting delta and gamma with the gain from repricing the option at the scenario share price.
first derivative of is the explicit spelling of derivative of. The compact forms are slope(Result, Input) and curvature(Result, Input). An if keeps its original test. At a threshold, the derivative follows the selected branch, even when the curve has a corner there.
Use deriv for derivative or wrt for with respect to in any derivative formula. For example, second deriv of Position Value wrt Share Price gives the same gamma.
To see where the number comes from, choose a first or second derivative in the editor’s function wizard and select Show the algebra. For Distance = Time^3, the first derivative is 3 * Time^2 and the second is 6 * Time. When a condition selects a branch, the displayed algebra is specific to that branch. For example, at exercise the call’s delta is Shares above the strike and 0 below it. The example shows a dash exactly at the strike, where the slope changes abruptly. A formula too large to display can still give a numeric derivative.
Prime notation gives the same derivatives. Write Position Value'(Share Price) for delta or Position Value''(Share Price) for gamma. For several sensitivities at once, write Slopes = Position Value'(Share Price, Volatility) and read the fields as Slopes.Share Price and Slopes.Volatility.
To inspect the algebra on the page, choose View → Show symbolic algebra. If you enter Distance'(Time) | Time = 5, the editor shows {3 * Time^2} just before the bar. The result at that trial point is 75. The surrounding document keeps its own value of Time.
Fractional derivatives
Time = 2
Response = Time ^ 3
Start Time = 0
Memory Effect = fractional derivative of Response of order 1.34 with respect to Time from Start Time
A fractional derivative takes account of how a result changes over an interval. Here Memory Effect is about 12.668. Change Start Time to 1 and it becomes about 10.663. Literally uses the left-sided Caputo definition for a smooth numeric calculation. Choose an order greater than zero and at most two. Put the starting point after from and choose a value at or below the current input. Both the order and the starting point can be numbers, document names or calculations in parentheses.
The short form is fractional deriv of Response of order 1.34 wrt Time from Start Time. At order 1 or 2 you get the ordinary first or second derivative. For a non-whole order, a fixed condition can select a branch. The calculation reports an error if the condition depends on the input being varied, or if the selected calculation uses abs on a varying value or if_error.
Read a table by name
Give an ordinary Markdown table a name by putting the assignment directly above it or at the start of its header row. A leading equals sign in a cell makes its contents an expression.
To display the formula itself, type '=A1 * 2. The cell shows =A1 * 2. In a sentence, close the quote before the next live value, as in The formula '=Days * 2' gives =(Days * 2).
Invoices =
| Client | Balance |
| --- | ---: |
| Atelier | =Balance Due |
| Harbour | =£450.00 |
Atelier owes =Balance from Invoices where Client = 'Atelier'.
To read a cell by position, write =Invoices.B1 in another table or in a sentence. It shows the balance in the first data row.
With the original deposit, that sentence reads “Atelier owes £1,800.00.” The lookup follows the column names even if another client is added above Atelier. One match supplies the value, zero matches give null, and multiple matches report an ambiguous result.
For a list of everyone who owes money, write =Invoices[Client, Balance | Balance > £0.00] on its own line. Read the bar as “where”. Show Client and Balance for each invoice where the balance is positive. You can also write =select Client, Balance from Invoices where Balance > £0.00.
Summarise a table with a pivot
pivot(Orders, "Region", "Quarter", "Revenue", "sum") gives one row per region and one column per quarter. Each cell totals the revenue of the matching orders. In the editor, choose Insert → Pivot table… to build it. Choose the interactive form to let a reader change the groupings or switch from a total to a count. Explore an interactive sales pivot.
Build a quote from a price list
Write Line Total = Quantity * Unit Price in a table heading and every empty cell in that column calculates its own row’s total. The inputs can be on either side. If you agree a different total for one item, enter it in that row. Clear it to go back to the usual calculation.
Write the catalogue as a Markdown table, then use based on Catalogue to build the quote. The catalogue shows all four columns. The quote inherits its rows, gives Price a discount parameter, adds a line total and hides the internal cost. Changing a catalogue price updates the quote.
Catalogue =
| Item | Quantity | Price | Cost |
| ---------- | -------: | ------: | ------: |
| Site visit | 2 | £150.00 | £90.00 |
| Report | 1 | £200.00 | £120.00 |
Trade Quote = based on Catalogue
Price(Discount = 0%) = Row.Price * (1 - Discount)
Total = Row.Quantity * Row.Price
hide Cost
=Trade Quote
A visit with a ten per cent discount costs =Trade Quote[1].Price(10%).
For a more compact table, write Catalogue = | Item | Quantity | Price | Cost | on the first line.
Trade Quote[1].Price gives the usual price of £150. Writing Trade Quote[1].Price(10%) gives £135 for that visit. The displayed quote still shows two visits at £150 and a total of £300.
Indent the changes under based on. The first rule reads the catalogue price. The next rule sees the calculated price at its default discount. Return to the left margin to display the table or carry on writing. You can base another table on Trade Quote in turn.
If you know object-oriented programming, the table’s column definitions play the part of a class and each row is an object. A calculated column that takes parameters acts like a method on that row. In Trade Quote[1].Price(10%), the first row supplies the site visit’s price and the caller supplies the discount.
Compare two discounts side by side
Volume Prices = based on Trade Quote[| Quantity >= 2]
"5% discount" = Row.Price(5%)
"10% discount" = Row.Price(10%)
=Volume Prices
Only the site visit row meets the quantity test. Its regular price is £150.00 and the two new columns show £142.50 and £135.00. Both use the same inherited pricing rule. Try different discounts on a print order.
Show different details for the same trade
An equity option can take its ticker from Equity Trades, which in turn takes its settlement terms from Trades. Ask Equity Options[1] is_a Trades and the answer is true, even with another table in between.
Pass that option to a trade summary to see its strike and exercise date, or to a settlement view to see the cash due. Each view receives the same row, including its calculations. Choose a ticket and try both views.
To connect a ticket to a details panel, write show #viewer when "Ticket" is clicked in Trade Blotter, setting Selected Ticket. The reader can close the details and keep the ticket selected for other calculations. In the editor, Insert → Row view… designs the layout and Insert → Selectable table… connects the click.
In the editor, Insert → Table based on… lets you keep, hide or change each column and preview the figures. To reuse wording from the same document, choose Insert → Reuse document sections…. A client version of a proposal can follow the original scope of work, omit internal notes and give payment terms their own wording.
Using rows, tables and formatted content in functions
In a tiles code block, function Price For(Line, Discount = 0%) = Line.Price * (1 - Discount) defines a reusable rule. Price For(Catalogue[1]) gives £150. Supplying 10% as a second argument gives £135. Put optional arguments after required ones.
with_column(Catalogue, "Price", Price For, 10%) uses that rule for every row. without_columns(Catalogue, "Cost") returns a table with the Cost column omitted. A function can also accept a whole table and read a column, for example sum(Lines["Total"]) when its argument is called Lines.
Pass strong("Approved") to a function that wraps it in paragraph("Decision: ", Content) and the word stays bold. Constructors also cover headings, sections, lists and columns. Images and editor controls written directly on the page have no corresponding function argument for selecting them by position.
Make a client edition
A desk heading and its client version can share wording. Give the client heading its own level and append two words to the original content. Any emphasis in the original follows it into the client version.
Desk Heading = heading(3, strong("Settlement"), " enquiries")
Client Heading = based on Desk Heading
Level = 2
Content = [Desk Heading.Content, " for clients"]
=Client Heading
The same idea applies to a whole document. The line below brings the desk report into another file, omits the agreements section and its subsections, and gives the cash section a new opening paragraph. Its individual trade headings and calculations still come from the desk report.
based on [Desk trade terms](trade-terms.lmd) hiding (#agreements) replacing (#cash = "Each payment includes the agreed **booking fee**.") as Desk
To make the same choices in the editor, choose Insert → Reuse document sections… → Version of another document. Enter the base document address, choose Load sections and pick which sections to keep, hide or reword.
The client edition also takes its contact heading from the desk report. Client Contact is_a Desk.Contact Heading returns true even though the client uses a different heading level. Open the client settlement statement or read its source.
Let another document use the result
Add these two lines at the top of the invoice to say what a caller may supply and what it can read back.
Provided: Agreed Fee, Deposit Paid
Outputs: Balance Due
A client portal can now supply the deposit and collect Balance Due as a sterling amount. The invoice uses the very same amount in its sentence. To try a different deposit inside the document, =Balance Due(Deposit Paid = £800.00) gives £1,600.00 while the original balance stays at £1,800.00.
Open the source of a fee proposal with inputs and an output.