Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Dim x_var = uc.DefineVariable("x")
      Dim i = 0
      
      '// --- Inefficient Way ---
      Console.WriteLine("--- Inefficient: Eval() in a loop ---")
      For i  = 1 To 3
         x_var.Value(i)
         Console.WriteLine(uc.Eval("x * x + 2"))
      Next
      
      Console.WriteLine("")
      
      '// --- High-Performance Way ---
      Console.WriteLine("--- Efficient: Parse() once, Evaluate() in a loop ---")
      '// Parse outside the loop
      Dim expr = uc.Parse("x * x + 2")
      For i  = 1 To 3
         x_var.Value(i)
         '// Evaluate the pre-parsed object
         Console.WriteLine(expr.Evaluate())
      Next
   End Sub
End Module