Pure Computation

This example demonstrates functions with no side effects.

-- AXIOM Example: Pure Computation
module examples.pure.math

fn factorial(n: UInt<64>) -> UInt<64> {
    match n {
        0 => 1,
        _ => n * factorial(n - 1),
    }
}

struct Point { x: Float<64>, y: Float<64> }

fn distance(a: Point, b: Point) -> Float<64> {
    let dx = a.x - b.x
    let dy = a.y - b.y
    sqrt(dx * dx + dy * dy)
}