flowcode-core 0.4.3-alpha

Core execution engine for FlowCode data scripting language
Documentation
// flowcode-core/src/util.rs

use crate::error::FCError;

/// Parses a vector of string arguments into a vector of f64 numbers.
/// Returns a Result with the vector of numbers or an error message string.
pub fn parse_numbers(args: &[String]) -> Result<Vec<f64>, FCError> {
    let mut numbers = Vec::new();
    if args.is_empty() {
        return Err(FCError::InsufficientData("No numbers provided".to_string()));
    }

    for arg in args {
        match arg.parse::<f64>() {
            Ok(num) => numbers.push(num),
            Err(_) => {
                return Err(FCError::ParseError(format!("Invalid number format: {}", arg)));
            }
        }
    }
    Ok(numbers)
}