sbool applyRule_all_debug; static void applyRule_all(S ruleID) { // process the rule Lisp rule = getLispTruth(ruleID); if (rule == null) { print("Rule not found: " + ruleID); ret; } //print("Applying rule " + ruleID); if (applyRule_all_debug) print_setPrefixForThread(ruleID + "> "); try { applyRule_all(rule, ruleID); } finally { if (applyRule_all_debug) print_setPrefixForThread(""); } } svoid applyRule_all(Lisp rule, S ruleID) { L conditions = dropLast(rule.args); Lisp out = last(rule.args); //for (Lisp cond : conditions) print("Condition: " + cond); L> results = matchConditions_all(conditions, new HashMap); if (applyRule_all_debug) { print("Got " + n(results, "results")); if (empty(results)) print(" " + n(matchConditions_random(conditions, new HashMap), "conditions") + " met of " + l(conditions)); } for (Map matches : results) { if (applyRule_all_debug) print("Yo! " + struct(matches)); out = lispReplaceVars(out, matches); if (lispTrue(out)) { if (applyRule_all_debug) print("Already had: " + out); } else { if (applyRule_all_debug) print("Defining: " + lispToEnglish_prettier(out)); emit(out, ruleID); } } }