static Map, Bool> ai_isRuleSuitableForFunction_cache = synchroHashMap(); static bool ai_isRuleSuitableForFunction(S rule, S f) { Pair p = pair(rule, f); Bool b = ai_isRuleSuitableForFunction_cache.get(p); if (b != null) ret b; pcall { try { callAndMake(f, rule, null); ai_isRuleSuitableForFunction_cache.put(p, true); true; } catch (UnsuitableRuleException e) { ai_isRuleSuitableForFunction_cache.put(p, false); false; } } throw new FunctionIsBroken; }