#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; void ucalc_call MyAverage(uCalcBase::Callback cb) { double Total = 0; for (int x = 1; x <= cb.ArgCount(); x++) { Total = Total + cb.Arg(x); } cb.Return(Total / cb.ArgCount()); } int main() { uCalc uc; auto MyArrayA = uc.DefineVariable("MyArrayA[] = {10, 20, 30, 40, 50}"); auto MyArrayB = uc.DefineVariable("MyArrayB[15]"); auto FunctionA = uc.DefineFunction("FuncA(x, y, z) = x + y + z"); auto FunctionB = uc.DefineFunction("FuncB(x, y, a = 12, b = 34) = x+y+a+b"); auto FunctionC = uc.DefineFunction("FuncC(x, y ...)", MyAverage); auto FunctionD = uc.DefineFunction("FuncD() = 1+1"); cout << "Elements in array (from initializer): " << MyArrayA.Count() << endl; cout << "Elements in array (from size): " << MyArrayB.Count() << endl; cout << "Parameters in FuncA() (fixed): " << FunctionA.Count() << endl; cout << "Parameters in FuncB() (with optional): " << FunctionB.Count() << endl; cout << "Parameters in FuncC() (variadic): " << FunctionC.Count() << endl; cout << "Parameters in FuncD() (none): " << FunctionD.Count() << endl; cout << "Operands in '!' operator (postfix): " << uc.ItemOf("!").Count() << endl; cout << "Operands in '>' operator (infix): " << uc.ItemOf(">").Count() << endl; }