Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1027180 // philosophyBot1_addSimplificationRule_withTrails

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (9251L/60K).

// e.g. in = "very $x", out = "$x"
svoid philosophyBot1_addSimplificationRule_withTrails(PhilosophyBot1 bot, S ruleIn, S ruleOut, S originalFact) {
  Set<T3S> replacements = cast bot.getExtension("simplification rules");
  if (replacements == null) {
    // first time, register extension and set up transformer
    bot.addExtension("simplification rules", replacements = new Set);
    Set<T3S> _replacements = replacements;
    bot.addTrailEnabledDeepTransformer(s -> {
      for (T3S p : _replacements) {
        S out = simpleRewriteWithDollarVars(p.a, p.b, s);
        if (out != null)
          ret WithTrail(litorderedmap(op := "simplification rule",
            +p, +s, +out, originalFact := p.c), out);
      }
      null;
    });
  }
  // after that, just add new replacement pair to the list
  replacements.add(t3(ruleIn, ruleOut, originalFact));
}

Author comment

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: 194 / 306
Version history: 7 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1027309 - philosophyBot1_addEnableableExtension