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

35
LINES

< > BotCompany Repo | #1027896 // AI_ExecuteSimpleForWhere [OK]

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

Libraryless. Click here for Pure Java version (3100L/20K).

// executes things like "hasWord($x) => ..."
sclass AI_ExecuteSimpleForWhere implements Steppable {
  // filled by user (necessary)
  ForWhere fw;
  DeepZipTools tools;
  
  // handle output
  swappable void addLogicRule(BasicLogicRule rule) {}
  
  // iterate values for function
  swappable Iterable elementsForFunction(S functionName) { null; }
  
  // internal variables
  O var;
  S functionName;
  Iterator elements;
  
  *() {}
  *(DeepZipTools *tools, IVF1<BasicLogicRule> *addLogicRule,
    IF1<S, Iterable> *elementsForFunction, ForWhere *fw) {}
  
  public bool step() {
    if (elements == null) {
      Pair p = forWhereParseSimpleFunctionCall(fw, tools);
      if (p == null) false;
      functionName = (S) p.b;
      var = p.a;
      elements = iterator(elementsForFunction(functionName));
    }
    
    if (!elements.hasNext()) false;
    addLogicRule((BasicLogicRule) tools.replaceVars(fw.body, litmap(var, elements.next())));
    true;
  }
}

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: #1027896
Snippet name: AI_ExecuteSimpleForWhere [OK]
Eternal ID of this version: #1027896/14
Text MD5: 0bb57b447f922bb1ffbaaa7102349894
Transpilation MD5: 1568ee5d100bad11b918d7e577cebd4b
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-04-18 11:45:26
Source code size: 995 bytes / 35 lines
Pitched / IR pitched: No / No
Views / Downloads: 292 / 683
Version history: 13 change(s)
Referenced in: [show references]