#[allow(dead_code)] use crate::ast::ArgValue;
use crate::FCError;
pub fn combine(args: &[ArgValue]) -> Result<f64, FCError> {
if args.is_empty() {
return Err(FCError::InsufficientData("combine requires at least one argument".to_string()));
}
let sum: f64 = args.iter().map(|arg| match arg {
ArgValue::Number(n) => *n,
_ => 0.0, }).sum();
Ok(sum)
}
pub fn combine_with_error_handling(args: &[ArgValue]) -> Result<f64, FCError> {
if args.len() < 3 {
return Err(FCError::InsufficientData("Expected at least 3 arguments: source1, source2, and on clause".to_string()));
}
let source1 = match args.get(0) {
Some(ArgValue::String(s)) => s.clone(),
Some(other) => return Err(FCError::InvalidArgument(format!("Expected String for source1, got {:?}", other))),
None => return Err(FCError::InsufficientData("Missing source1 data".to_string())),
};
let source2 = match args.get(1) {
Some(ArgValue::String(s)) => s.clone(),
Some(other) => return Err(FCError::InvalidArgument(format!("Expected String for source2, got {:?}", other))),
None => return Err(FCError::InsufficientData("Missing source2 data".to_string())),
};
let on_clause = match args.get(2) {
Some(ArgValue::String(s)) => s.clone(),
Some(other) => return Err(FCError::InvalidArgument(format!("Expected string for on clause, got {:?}", other))),
None => return Err(FCError::InsufficientData("Missing on clause for combination".to_string())),
};
let combined_data = format!("Combined data from {} and {} on {}", source1, source2, on_clause);
println!("{}", combined_data); Ok(0.0) }