All examples
Language

Concise checked research code

Combine constant defaults, inferred outcome constructors, checked array selectors and Result propagation in a complete local program.

research_syntax.aner
// Requires the updated native development runtime with research syntax support.
// Complete local example: defaults, outcome inference/propagation and checked indexing.
import aner.math

fn scale(value: Float64, factor: Float64 = 2.0) -> Float64 {
    return value * factor
}
fn positive_root(value: Float64) -> Result<Float64, String> {
    if value < 0.0 { return Result.err("value must be nonnegative") }
    return Result.ok(math.sqrt(value))
}
fn labeled_root(value: Float64) -> Result<String, String> {
    let root = positive_root(value)?
    return Result.ok("root=" + String(root))
}

let missing: Optional<Float64> = Optional.none()
let nested: Result<Optional<Int64>, String> = Result.ok(Optional.none())
let readings = Array<Float64>(size: 3, fill: 0.0)
readings[0] = 3.0
readings[1] = 4.0
var squares = 0.0
for index in Range(readings.len()) {
    squares += math.pow(readings[index], 2.0)
}
let matrix = NDArray<Float64>(shape: List(2, 2), fill: 0.0)
matrix[1, 1] = math.sqrt(squares)
matrix[1, 1] += 1.0
var count = 3
count *= 4
count /= 2
count -= 1

print(scale(3.0))
print(scale(factor: 4.0, value: 3.0))
print(missing.is_none())
print(nested.unwrap().is_none())
print(matrix[1, 1])
print(count)
print(labeled_root(25.0).unwrap())
print(labeled_root(-1.0).unwrap_err())

Make it your experiment.

With Aner installed, save this program as examples/research_syntax.aner inside a folder for your experiment. Open a terminal in that folder, then check and run the program.

Terminal
aner check examples/research_syntax.aner
aner run examples/research_syntax.aner

The aner command must be on your PATH. Follow the installation guide if your terminal cannot find it.

Use the updated native Aner development runtime with aner.math, defaults, contextual outcome constructors, checked array selectors and Result propagation. Older packaged executables may predate this syntax. Build the current source or select a compatible updated development executable; the guide distinguishes implemented capabilities from planned unit bearing arrays, records and typed parallel results. The revised source requires the updated development runtime; older packaged executables may reject the new syntax.

Bundled datasets retain their own source attribution and license notices. Example outcomes are not comparative benchmarks or evidence of clinical validity.

Dataset sources & attribution
Install Aner