svoid applyRule_all_random(S ruleID) { // process the rule Lisp rule = getLispTruth(ruleID); if (rule == null) { print("Rule not found: " + ruleID); ret; } //print("Applying rule " + ruleID); print_setPrefixForThread(ruleID + "> "); try { L<Lisp> conditions = dropLast(rule.args); Lisp out = last(rule.args); L<Map<S, Lisp>> results = matchConditions_all(conditions, new HashMap); print("Got " + n(results, "results")); if (empty(results)) ret; Map<S, Lisp> matches = random(results); print("Yo! " + struct(matches)); out = lispReplaceVars(out, matches); print("Possibly defining: " + lispToEnglish_prettier(out)); emit(out, ruleID); } finally { print_setPrefixForThread(""); } }
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: | 767 / 769 |
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |