ganit-core 0.3.4

Spreadsheet formula engine — parser and evaluator for Excel-compatible formulas
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::types::{ErrorKind, Value};
use super::stat_helpers::collect_nums_a;
use super::var_p::pop_variance;

/// `VARPA(value1, ...)` — population variance, text/FALSE=0, TRUE=1.
pub fn varpa_fn(args: &[Value]) -> Value {
    if args.is_empty() {
        return Value::Error(ErrorKind::NA);
    }
    if args.iter().any(|a| matches!(a, Value::Text(_))) {
        return Value::Error(ErrorKind::Value);
    }
    let nums = collect_nums_a(args);
    pop_variance(&nums)
}

#[cfg(test)]
mod tests;