Internal Test: Verifies that `{@@Eval}` can correctly parse and evaluate an expression that is itself captured from the text.
ID: 1220
using uCalcSoftware;
var uc = new uCalc();
var t = new uCalc.Transformer();
// The variable {formula} will capture the literal text "10 * (5-2)".
// {@@Eval} then executes that text as an expression.
t.FromTo("solve({formula})", "'{formula}' is {@@Eval: formula}.");
var text = "The answer to solve(10 * (5-2))";
Console.WriteLine(t.Transform(text));
The answer to '10 * (5-2)' is 30. using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); // The variable {formula} will capture the literal text "10 * (5-2)". // {@@Eval} then executes that text as an expression. t.FromTo("solve({formula})", "'{formula}' is {@@Eval: formula}."); var text = "The answer to solve(10 * (5-2))"; Console.WriteLine(t.Transform(text));
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
uCalc::Transformer t;
// The variable {formula} will capture the literal text "10 * (5-2)".
// {@@Eval} then executes that text as an expression.
t.FromTo("solve({formula})", "'{formula}' is {@@Eval: formula}.");
auto text = "The answer to solve(10 * (5-2))";
cout << t.Transform(text) << endl;
}
The answer to '10 * (5-2)' is 30. #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; // The variable {formula} will capture the literal text "10 * (5-2)". // {@@Eval} then executes that text as an expression. t.FromTo("solve({formula})", "'{formula}' is {@@Eval: formula}."); auto text = "The answer to solve(10 * (5-2))"; cout << t.Transform(text) << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t As New uCalc.Transformer()
'// The variable {formula} will capture the literal text "10 * (5-2)".
'// {@@Eval} then executes that text as an expression.
t.FromTo("solve({formula})", "'{formula}' is {@@Eval: formula}.")
Dim text = "The answer to solve(10 * (5-2))"
Console.WriteLine(t.Transform(text))
End Sub
End Module
The answer to '10 * (5-2)' is 30. Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t As New uCalc.Transformer() '// The variable {formula} will capture the literal text "10 * (5-2)". '// {@@Eval} then executes that text as an expression. t.FromTo("solve({formula})", "'{formula}' is {@@Eval: formula}.") Dim text = "The answer to solve(10 * (5-2))" Console.WriteLine(t.Transform(text)) End Sub End Module