Lessons: in your program

Ten short lessons on using Leonardo as a library — a dependency in your own Scala code, called from your own types. Each one builds something small and ends with an exercise, and the last one assembles the rest into a working program.

Start with L1 — Reading an expression.

If you would rather type at a prompt than write Scala, the other branch is Lessons: at the prompt — it needs no installation at all, and it is a quick way to get a feel for the expression language before you embed it.

The lessons

     
L1 Reading an expression Parser.parse, its result type, and the failure that is not one
L2 The dual evaluation model Either[_Expression, _Value], and why Left is not an error
L3 Environment Binding, scoped evaluation, and why rounding is display-only
L4 Building trees without the parser The _-prefixed nodes, and Syntax sugar
L5 Traversal children / rebuild, freeVars, dependsOn
L6 The calculus API derive, integrate, simplify, normalize
L7 Numbers The widening extractor and the exact tier
L8 Embedding a Session String in, string out — the bridge to the REPL
L9 Refusals Left, None, and what “stays symbolic” obliges you to handle
L10 A small application, end to end The payoff
L11 Matrices Two carriers, structural dispatch, rows of results

L1–L10 are the arc; later lessons each open one part of the API whose shape is not obvious from its reference page, matrices first. The reference pages cover the other domains — equations, logic, transforms, differential equations, statistics, vector calculus and control theory — in the same language these lessons teach.

What this branch assumes

That you can add a dependency to a Scala 3 build and read a match. It does not assume you know what a computer algebra system is, and it does not teach the mathematics — it teaches how to express a problem to the library and how to read what comes back.

The arc

The first three lessons are the model: parsing, the dual evaluation result, and the environment that binds names. The middle four are the working surface: building trees, traversing them, the calculus functions, and the number tiers. The last three are what separates a demonstration from a program: embedding a session, reading the library’s refusals, and one small application end to end.

Every example on these pages is compiled and executed when the site is built, so the code cannot drift from the library and the results are the library’s own.

Before you start

Getting Started has the artifact coordinates, the two-artifact split and the import conventions. These lessons assume it only for the dependency line, which L1 repeats.


Table of contents


This site uses Just the Docs, a documentation theme for Jekyll.