1 | svoid applyRule_all_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 | |
11 | L<Map<S, Lisp>> results = matchConditions_all(conditions, new HashMap); |
12 | print("Got " + n(results, "results")); |
13 | if (empty(results)) ret; |
14 | Map<S, Lisp> matches = random(results); |
15 | print("Yo! " + struct(matches)); |
16 | out = lispReplaceVars(out, matches); |
17 | print("Possibly defining: " + lispToEnglish_prettier(out)); |
18 | emit(out, ruleID); |
19 | } finally { |
20 | print_setPrefixForThread(""); |
21 | } |
22 | } |
Began life as a copy of #1008135
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: | #1008137 |
Snippet name: | applyRule_all_random - choose one of all solutions |
Eternal ID of this version: | #1008137/1 |
Text MD5: | b4caf3adf78e45739a9c2825450cc2ad |
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 17:28:16 |
Source code size: | 763 bytes / 22 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 554 / 540 |
Referenced in: | [show references] |