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.
// Also valid with --strict-declarations: let keeps handles fixed; var marks reassignments.
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 = integer_div(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.

Use Aner 0.0.3 or newer. 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 Aner 0.0.4 or newer with aner.math, defaults, contextual outcome constructors, checked array selectors and Result propagation. Use a compatible runtime with the documented capabilities; records and typed parallel results remain planned. The revised source requires Aner 0.0.4 or newer; earlier executables may reject the 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