1 | svoid applyRule_random(S ruleID) { |
2 | // process the rule |
3 | Lisp rule = getLispTruth(ruleID); |
4 | if (rule == null) { print("Rule not found: " + ruleID); ret; } |
5 | //print("Applying rule " + ruleID); |
6 | print_setPrefixForThread(ruleID + "> "); |
7 | try { |
8 | L<Lisp> conditions = dropLast(rule.args); |
9 | Lisp out = last(rule.args); |
10 | //for (Lisp cond : conditions) print("Condition: " + cond); |
11 | |
12 | new Map<S, Lisp> matches; |
13 | int n = matchConditions_random(conditions, matches); |
14 | if (n == -1) { |
15 | print("Yo! " + struct(matches)); |
16 | out = lispReplaceVars(out, matches); |
17 | if (lispTrue(out)) |
18 | print("Already had: " + out); |
19 | else { |
20 | print("Defining: " + lispToEnglish_prettier(out)); |
21 | emit(out, ruleID); |
22 | } |
23 | } else |
24 | print("Only " + n + " of " + n(conditions, "condition") + " met"); |
25 | } finally { |
26 | print_setPrefixForThread(""); |
27 | } |
28 | } |
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: | #1008135 |
Snippet name: | applyRule_random |
Eternal ID of this version: | #1008135/1 |
Text MD5: | 4db969f58581fd44b695e0a89a07080e |
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-25 16:41:35 |
Source code size: | 920 bytes / 28 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 473 / 490 |
Referenced in: | [show references] |