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
ExampleWhat it shows
matrix_basics.dnVectors and matrices from the matrix module.
vector_stats.dnReductions and statistics over a vector.
linear_regression.dnA small numerical program: least-squares fit.
statistical_analysis.dnDescriptive statistics, regression, histograms, probability helpers, and matrix/plot integration.
collection_pipeline.dnThe higher-order filter/map/sum pipeline with function values.
functions_and_closures.dnTyped lambdas, capture snapshots, shared aggregate handles, nested/generic closures, stored closures, composition, callbacks, and callable-expression chains.
defer_cleanup.dnDeterministic resource cleanup with defer: LIFO, captures, early exits, ?, and loop scopes.
geometry.dn + geometry_demo.dnA two-file program showing module declarations, aliases, and selective imports.
documented.dnEvery 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.