1 | // returns true if it fired |
2 | static bool applyRule_first(S ruleID) {
|
3 | // process the rule |
4 | Lisp rule = getLispTruth(ruleID); |
5 | if (rule == null) { print("Rule not found: " + ruleID); false; }
|
6 | //print("Applying rule " + ruleID);
|
7 | print_setPrefixForThread(ruleID + "> "); |
8 | try {
|
9 | ret applyRule_first(rule, ruleID); |
10 | } finally {
|
11 | print_setPrefixForThread("");
|
12 | } |
13 | } |
14 | |
15 | // ruleID is just as an info parameter to emit() |
16 | static bool applyRule_first(Lisp rule, S ruleID) {
|
17 | L<Lisp> conditions = dropLast(rule.args); |
18 | Lisp out = last(rule.args); |
19 | |
20 | L<Map<S, Lisp>> results = matchConditions_all(conditions, new HashMap); // can be optimized |
21 | //print("Got " + n(results, "results"));
|
22 | if (empty(results)) false; |
23 | Map<S, Lisp> matches = first(results); |
24 | //print("Yo! " + struct(matches));
|
25 | out = lispReplaceVars(out, matches); |
26 | //print("Possibly defining: " + lispToEnglish_prettier(out));
|
27 | emit(out, ruleID); |
28 | true; |
29 | } |
Began life as a copy of #1008134
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1008136 |
| Snippet name: | applyRule_first |
| Eternal ID of this version: | #1008136/7 |
| Text MD5: | 00cbebd883f41bb6d20b25a2721456dd |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2017-04-30 15:04:20 |
| Source code size: | 956 bytes / 29 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 730 / 759 |
| Version history: | 6 change(s) |
| Referenced in: | [show references] |