#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.ExpressionTransformer(); // Base case: a single argument t.FromTo("AddUp({x})", "{x}"); // Recursive case: multiple arguments // RewindOnChange(true) causes the transformer to re-scan the string after a replacement. // This allows AddUp(1,2,3) -> (1 + AddUp(2,3)) -> (1 + (2 + AddUp(3))) -> (1 + (2 + 3)) t.FromTo("AddUp({x}, {y})", "({x} + AddUp({y}))").RewindOnChange(true); cout << "Input: AddUp(1, 2, 3, 4)" << endl; cout << "Result: " << uc.Eval("AddUp(1, 2, 3, 4)") << endl; }