Demonstrates the pass/fail behavior of GlobalMinimum. If the rule doesn't find at least 3 'a's, the entire transform fails.
ID: 882
using uCalcSoftware;
var uc = new uCalc();
var t = uc.NewTransformer();
var ruleA = t.FromTo("a", "A");
var ruleB = t.FromTo("b", "B");
ruleA.GlobalMinimum = 3;
// Case 1: Fails (only 2 'a's)
Console.WriteLine("--- Case 1: Fails ---");
t.Text = "a b a b";
t.Transform();
Console.WriteLine($"Matches Found: {t.Matches.Count()}"); // Should be 0
Console.WriteLine($"Result: {t}");
// Case 2: Succeeds (3 'a's)
Console.WriteLine("");
Console.WriteLine("--- Case 2: Succeeds ---");
t.Text = "a b a b a";
t.Transform();
Console.WriteLine($"Matches Found: {t.Matches.Count()}"); // Should be 5 (3 'A's and 2 'B's)
Console.WriteLine($"Result: {t}");
--- Case 1: Fails ---
Matches Found: 0
Result: a b a b
--- Case 2: Succeeds ---
Matches Found: 5
Result: A B A B A using uCalcSoftware; var uc = new uCalc(); var t = uc.NewTransformer(); var ruleA = t.FromTo("a", "A"); var ruleB = t.FromTo("b", "B"); ruleA.GlobalMinimum = 3; // Case 1: Fails (only 2 'a's) Console.WriteLine("--- Case 1: Fails ---"); t.Text = "a b a b"; t.Transform(); Console.WriteLine($"Matches Found: {t.Matches.Count()}"); // Should be 0 Console.WriteLine($"Result: {t}"); // Case 2: Succeeds (3 'a's) Console.WriteLine(""); Console.WriteLine("--- Case 2: Succeeds ---"); t.Text = "a b a b a"; t.Transform(); Console.WriteLine($"Matches Found: {t.Matches.Count()}"); // Should be 5 (3 'A's and 2 'B's) Console.WriteLine($"Result: {t}");
#include
#include "uCalc.h"
using namespace std;
using namespace uCalcSoftware;
int main() {
uCalc uc;
auto t = uc.NewTransformer();
auto ruleA = t.FromTo("a", "A");
auto ruleB = t.FromTo("b", "B");
ruleA.GlobalMinimum(3);
// Case 1: Fails (only 2 'a's)
cout << "--- Case 1: Fails ---" << endl;
t.Text("a b a b");
t.Transform();
cout << "Matches Found: " << t.Matches().Count() << endl; // Should be 0
cout << "Result: " << t << endl;
// Case 2: Succeeds (3 'a's)
cout << "" << endl;
cout << "--- Case 2: Succeeds ---" << endl;
t.Text("a b a b a");
t.Transform();
cout << "Matches Found: " << t.Matches().Count() << endl; // Should be 5 (3 'A's and 2 'B's)
cout << "Result: " << t << endl;
}
--- Case 1: Fails ---
Matches Found: 0
Result: a b a b
--- Case 2: Succeeds ---
Matches Found: 5
Result: A B A B A #include <iostream> #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; auto t = uc.NewTransformer(); auto ruleA = t.FromTo("a", "A"); auto ruleB = t.FromTo("b", "B"); ruleA.GlobalMinimum(3); // Case 1: Fails (only 2 'a's) cout << "--- Case 1: Fails ---" << endl; t.Text("a b a b"); t.Transform(); cout << "Matches Found: " << t.Matches().Count() << endl; // Should be 0 cout << "Result: " << t << endl; // Case 2: Succeeds (3 'a's) cout << "" << endl; cout << "--- Case 2: Succeeds ---" << endl; t.Text("a b a b a"); t.Transform(); cout << "Matches Found: " << t.Matches().Count() << endl; // Should be 5 (3 'A's and 2 'B's) cout << "Result: " << t << endl; }
Imports System
Imports uCalcSoftware
Public Module Program
Public Sub Main()
Dim uc As New uCalc()
Dim t = uc.NewTransformer()
Dim ruleA = t.FromTo("a", "A")
Dim ruleB = t.FromTo("b", "B")
ruleA.GlobalMinimum = 3
'// Case 1: Fails (only 2 'a's)
Console.WriteLine("--- Case 1: Fails ---")
t.Text = "a b a b"
t.Transform()
Console.WriteLine($"Matches Found: {t.Matches.Count()}") '// Should be 0
Console.WriteLine($"Result: {t}")
'// Case 2: Succeeds (3 'a's)
Console.WriteLine("")
Console.WriteLine("--- Case 2: Succeeds ---")
t.Text = "a b a b a"
t.Transform()
Console.WriteLine($"Matches Found: {t.Matches.Count()}") '// Should be 5 (3 'A's and 2 'B's)
Console.WriteLine($"Result: {t}")
End Sub
End Module
--- Case 1: Fails ---
Matches Found: 0
Result: a b a b
--- Case 2: Succeeds ---
Matches Found: 5
Result: A B A B A Imports System Imports uCalcSoftware Public Module Program Public Sub Main() Dim uc As New uCalc() Dim t = uc.NewTransformer() Dim ruleA = t.FromTo("a", "A") Dim ruleB = t.FromTo("b", "B") ruleA.GlobalMinimum = 3 '// Case 1: Fails (only 2 'a's) Console.WriteLine("--- Case 1: Fails ---") t.Text = "a b a b" t.Transform() Console.WriteLine($"Matches Found: {t.Matches.Count()}") '// Should be 0 Console.WriteLine($"Result: {t}") '// Case 2: Succeeds (3 'a's) Console.WriteLine("") Console.WriteLine("--- Case 2: Succeeds ---") t.Text = "a b a b a" t.Transform() Console.WriteLine($"Matches Found: {t.Matches.Count()}") '// Should be 5 (3 'A's and 2 'B's) Console.WriteLine($"Result: {t}") End Sub End Module