// Development native CPU subset. Build requires the matching source-build SDK.
// aner build examples/native_numeric.aner -o /tmp/aner-native-numeric
// /tmp/aner-native-numeric
import aner.math

fn transform(values: Array<Float64>, factor: Float64) -> Array<Float64> {
    let output = values.copy()
    for index in Range(output.len()) {
        output[index] = math.sqrt(values[index] * factor)
    }
    return output
}

fn accumulate(values: Array<Float64>) -> Float64 {
    var total = 0.0
    var index = 0
    while index < values.len() {
        total += values[index]
        index += 1
    }
    return total
}

let samples = Array<Float64>(size: 4, fill: 9.0)
let transformed = transform(factor: 4.0, values: samples)
print(accumulate(transformed))
print(samples[0])
