lmr API guide

Overview

lmr is a native LMScript host that implements a fixed catalog of statistical operations. The C++17 runtime does not require an R installation. Its public schema and operation signatures are embedded in each release binary.

Check the host

lmr --version
lmr --lmcode-schema
lmr --lmcode-schema --json
lmr --lmcode-signatures
lmr --lmcode FILE.dslb

Write blocks as p = _lmcode_ cli="lmr" install="github:lmctl-ai/lmr@latest"; ... end _lmcode_ and execute them with r = run_lmcode(p), which returns ok and result. cli="lmr" compiles against the embedded schema and the install declaration fetches the release binary when lmr is not on PATH. The host schema contains only lmr-specific declarations: the out context object, 166 functions and 50 types. Standard types such as StrList come from the vendored lmcode_std_v3 library, which has 206 signatures in this repository; the current upstream catalog has 226 including the REST and CLI interfaces, and lmr does not ship those until it syncs its SDK pin.

Operation catalog

AreaOperations
Distributions and random valuesDist.q, Dist.d, Dist.p, Rng.draw, Rng.sample, Vec.quantiles
Tests and modelstest(kind).run(), lm, glm, nls
Time seriesfft, arima, arima_sim, Vec.acf, Vec.pacf, stl
Smoothing and interpolationsmooth_spline, loess, spline_fun, approx_fun
Clusteringkmeans, hclust
Numerical methodsminimize, optimize, uniroot, integrate

Results and errors

The DSL exposes typed result objects. Use out.set to include selected values in the run result: run_lmcode returns them as result.values, alongside result.checks and result.failures. Non-finite numeric values serialize as JSON null. out.print writes to stderr. Load and execution errors produce a JSON error with a phase, code, and message.

In the native host, process exit codes are 0 for success, 2 for usage errors, 3 for bytecode loading or execution errors, and 4 for failed application checks.

Limits

Limits depend on the native operation; the old R-backed API limits do not describe this host. Keep examples small and check operation-specific errors when increasing input sizes. Read the operation descriptions in the lmr API source for additional limits and supported options.

Examples

Start with the generated example book and the reference of every signature. The repository also provides longer LMScript tutorials and R comparison recipes.