Libraryless. Click here for Pure Java version (9838L/64K).
1 | svoid pb_enableAutoPatterns(PhilosophyBot1 bot, O... _) { |
2 | optPar bool debug; |
3 | if (debug) |
4 | print("pb_enableAutoPatterns"); |
5 | Set<S> patterns = ciSet(); |
6 | IVF1<S> onFact = fact -> bot.addFacts(dm_topDownParseToGroupings(fact, patterns)); |
7 | IVF1<PhilosophyBot1.LogicRule> onRule = rule -> { |
8 | LS l = uniquifyCI(map(lhs -> philosophyBot_varsToStars(bot, lhs), |
9 | stringsOnly(philosophyBot_allPartsOfLHS(rule)))); |
10 | if (debug) |
11 | print("Patterns in " + rule + ": " + l); |
12 | LS l2 = listMinusSet(l, patterns); |
13 | if (nempty(l2)) { |
14 | if (debug) print("Have new patterns: " + l2); |
15 | patterns.addAll(l2); |
16 | bot.updateCodeOnFact(onFact); |
17 | } |
18 | }; |
19 | bot.addCodeOnFact(onFact); |
20 | bot.addCodeOnRule(onRule); |
21 | } |
download show line numbers debug dex old transpilations
Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1027421 |
Snippet name: | pb_enableAutoPatterns - grab patterns from every rule, top-down parse every new fact |
Eternal ID of this version: | #1027421/11 |
Text MD5: | 4d39fe3678dff34c13d3f7add9d416ca |
Transpilation MD5: | c1044caf86e79cfb087e87025aafd02b |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-03-18 19:28:25 |
Source code size: | 749 bytes / 21 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 203 / 322 |
Version history: | 10 change(s) |
Referenced in: | [show references] |