fn evaluate_unary_numeric(
arg: &Expr,
state: &mut EvaluationState,
traversal_state: &mut StateManager,
fns: &FunctionMap,
transform: impl FnOnce(f64) -> f64,
) -> Option<EvaluateResultValue>Expand description
Helper function to evaluate unary numeric operations (Plus, Minus, Tilde). This reduces code duplication for operations that convert an expression to a number, apply a transformation, and return the result as an expression.
§Arguments
arg- The expression argument to the unary operatorstate- The evaluation statetraversal_state- The state manager for traversal contextfns- The function map for evaluating function callstransform- A function to transform the numeric value
§Example
ⓘ
UnaryOp::Plus => evaluate_unary_numeric(&arg, state, traversal_state, fns, |v| v),
UnaryOp::Minus => evaluate_unary_numeric(&arg, state, traversal_state, fns, |v| -v),