#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Define a variable 'x' that will be updated in the loop.
   auto variableX = uc.DefineVariable("x");

   // Parse the expression just once before the loop begins.
   auto parsedExpr = uc.Parse("x^2 * 10");

   cout << "Evaluating 'x^2 * 10' for x = 1 to 5:" << endl;
   for (double x = 1; x <= 5; x++) {
      variableX.Value(x);
      // Evaluate is very fast as the parsing work is already done.
      cout << "x = " << x << ", Result = " << parsedExpr.Evaluate() << endl;
   }
}