Examples
Runnable examples live in the examples/ directory and are covered by golden
output tests. Run any of them with the dune binary:
dune examples/matrix_basics.dn
| Example | What it shows |
|---|---|
matrix_basics.dn | Vectors and matrices from the matrix module. |
vector_stats.dn | Reductions and statistics over a vector. |
linear_regression.dn | A small numerical program: least-squares fit. |
statistical_analysis.dn | Descriptive statistics, regression, histograms, probability helpers, and matrix/plot integration. |
collection_pipeline.dn | The higher-order filter/map/sum pipeline with function values. |
functions_and_closures.dn | Typed lambdas, capture snapshots, shared aggregate handles, nested/generic closures, stored closures, composition, callbacks, and callable-expression chains. |
defer_cleanup.dn | Deterministic resource cleanup with defer: LIFO, captures, early exits, ?, and loop scopes. |
geometry.dn + geometry_demo.dn | A two-file program showing module declarations, aliases, and selective imports. |
documented.dn | Every comment form plus brief/param/returns doc-comments on a function, record fields, and a method. |
The documented.dn example is a good starting point for seeing how
doc-comments render on hover in an editor — open it with the
Zed extension and hover the documented names.
Interactive examples live under examples/notebooks/. Open
functions_and_closures.dnb for an unexecuted, cell-by-cell tour of lambdas,
capture semantics, nested and generic closures, callback pipelines, and plot
integration.