A simple demonstration of parsing an expression once and then evaluating it.
ID: 573
See: Evaluate
using uCalcSoftware;
var uc = new uCalc();
// 1. Parse the expression into a reusable object.
var parsedExpr = uc.Parse("100 / 4");
// 2. Evaluate the pre-parsed object.
Console.WriteLine($"Result: {parsedExpr.Evaluate()}");
Result: 25 using uCalcSoftware; var uc = new uCalc(); // 1. Parse the expression into a reusable object. var parsedExpr = uc.Parse("100 / 4"); // 2. Evaluate the pre-parsed object. Console.WriteLine($"Result: {parsedExpr.Evaluate()}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
// 1. Parse the expression into a reusable object.
auto parsedExpr = uc.Parse("100 / 4");
// 2. Evaluate the pre-parsed object.
cout << "Result: " << parsedExpr.Evaluate() << endl;
}
Result: 25 #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; // 1. Parse the expression into a reusable object. auto parsedExpr = uc.Parse("100 / 4"); // 2. Evaluate the pre-parsed object. cout << "Result: " << parsedExpr.Evaluate() << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
'// 1. Parse the expression into a reusable object.
Dim parsedExpr = uc.Parse("100 / 4")
'// 2. Evaluate the pre-parsed object.
Console.WriteLine($"Result: {parsedExpr.Evaluate()}")
End Sub
End Module
Result: 25 Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() '// 1. Parse the expression into a reusable object. Dim parsedExpr = uc.Parse("100 / 4") '// 2. Evaluate the pre-parsed object. Console.WriteLine($"Result: {parsedExpr.Evaluate()}") End Sub End Module