Warning: session_start(): open(/var/lib/php/sessions/sess_pn25lpvpi05ehar7ktav4rb3o4, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
scope gazelle_addCalculationFunctionsToRules.
sclass #Calculator {
S var1, var2, var3;
O function; // func(double, double) -> double
bool debug;
*() {}
*(S *var1, S *var2, S *var3, O *function, bool *debug) {}
SS get(SS map, LS tokC, LS tokI, RuleEngine2_MatchedRule matched) {
if (map == null) null;
double result;
try {
S value1 = getOrKeep(map, var1), value2 = getOrKeep(map, var2);
result = cast callAndMake_orF2(function, parseDouble(value1), parseDouble(value2));
} catch {
null;
}
if (!strictPutIC(map, var3, str(iround(result)))) null;
ret map;
}
}
svoid gazelle_addCalculationFunctionsToRules(RuleEngine2 engine, O... _) {
bool debug = boolPar debug(_) || boolPar calcDebug(_);
for (final RuleEngine2.Rule r : engine.rules)
for (Matches m : getJMatches_all("compute var * from * and * using *", r.comments)) {
r.addMapMassager(new Calculator($2, $3, $1, $4, debug));
if (debug) print("Calculator made");
}
}
end scope