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).

1  
// executes things like "hasWord($x) => ..."
2  
sclass AI_ExecuteSimpleForWhere implements Steppable {
3  
  // filled by user (necessary)
4  
  ForWhere fw;
5  
  DeepZipTools tools;
6  
  
7  
  // handle output
8  
  swappable void addLogicRule(BasicLogicRule rule) {}
9  
  
10  
  // iterate values for function
11  
  swappable Iterable elementsForFunction(S functionName) { null; }
12  
  
13  
  // internal variables
14  
  O var;
15  
  S functionName;
16  
  Iterator elements;
17  
  
18  
  *() {}
19  
  *(DeepZipTools *tools, IVF1<BasicLogicRule> *addLogicRule,
20  
    IF1<S, Iterable> *elementsForFunction, ForWhere *fw) {}
21  
  
22  
  public bool step() {
23  
    if (elements == null) {
24  
      Pair p = forWhereParseSimpleFunctionCall(fw, tools);
25  
      if (p == null) false;
26  
      functionName = (S) p.b;
27  
      var = p.a;
28  
      elements = iterator(elementsForFunction(functionName));
29  
    }
30  
    
31  
    if (!elements.hasNext()) false;
32  
    addLogicRule((BasicLogicRule) tools.replaceVars(fw.body, litmap(var, elements.next())));
33  
    true;
34  
  }
35  
}

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: 294 / 686
Version history: 13 change(s)
Referenced in: [show references]