Libraryless. Click here for Pure Java version (9251L/60K).
1 | // e.g. in = "very $x", out = "$x" |
2 | svoid philosophyBot1_addSimplificationRule_withTrails(PhilosophyBot1 bot, S ruleIn, S ruleOut, S originalFact) {
|
3 | Set<T3S> replacements = cast bot.getExtension("simplification rules");
|
4 | if (replacements == null) {
|
5 | // first time, register extension and set up transformer |
6 | bot.addExtension("simplification rules", replacements = new Set);
|
7 | Set<T3S> _replacements = replacements; |
8 | bot.addTrailEnabledDeepTransformer(s -> {
|
9 | for (T3S p : _replacements) {
|
10 | S out = simpleRewriteWithDollarVars(p.a, p.b, s); |
11 | if (out != null) |
12 | ret WithTrail(litorderedmap(op := "simplification rule", |
13 | +p, +s, +out, originalFact := p.c), out); |
14 | } |
15 | null; |
16 | }); |
17 | } |
18 | // after that, just add new replacement pair to the list |
19 | replacements.add(t3(ruleIn, ruleOut, originalFact)); |
20 | } |
Began life as a copy of #1027154
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: | #1027180 |
| Snippet name: | philosophyBot1_addSimplificationRule_withTrails |
| Eternal ID of this version: | #1027180/8 |
| Text MD5: | dbddd30ddccf6313f67f4d662bef54be |
| Transpilation MD5: | f63e636e374efc436da1d8dfbfbd0864 |
| Author: | stefan |
| Category: | javax / a.i. |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2020-02-24 21:13:56 |
| Source code size: | 877 bytes / 20 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 385 / 536 |
| Version history: | 7 change(s) |
| Referenced in: | [show references] |