// returns true if it fired static bool applyRule_first(S ruleID) { // process the rule Lisp rule = getLispTruth(ruleID); if (rule == null) { print("Rule not found: " + ruleID); false; } //print("Applying rule " + ruleID); print_setPrefixForThread(ruleID + "> "); try { ret applyRule_first(rule, ruleID); } finally { print_setPrefixForThread(""); } } // ruleID is just as an info parameter to emit() static bool applyRule_first(Lisp rule, S ruleID) { L conditions = dropLast(rule.args); Lisp out = last(rule.args); L> results = matchConditions_all(conditions, new HashMap); // can be optimized //print("Got " + n(results, "results")); if (empty(results)) false; Map matches = first(results); //print("Yo! " + struct(matches)); out = lispReplaceVars(out, matches); //print("Possibly defining: " + lispToEnglish_prettier(out)); emit(out, ruleID); true; }