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

24
LINES

< > BotCompany Repo | #1021892 // gazelle_proposeCalculationFunctions [dev.]

JavaX fragment (include)

// returns comments
static LS gazelle_proposeCalculationFunctions(S ruleText, ai_gazelle_analyzeStatementsForRule_Data data) {
  PairS rule = splitAtDoubleArrow_pair(ruleText);
  S var1 = firstIntAsString(rule.a), var2 = secondIntAsString(rule.a);
  S var3 = firstIntAsString(rule.b);
  if (var1 == null || var2 == null || var3 == null) ret emptyList();
  
  LS functions = ai_numberCalculationFunctions();
  for (SS map : listPlus(data.completeGoodMappings, null)) {
    if (empty(functions)) null;
    L<Double> numbers = ll(parseDouble(getOrKeep(map, var1)),
      parseDouble(getOrKeep(map, var2)));
    double result = parseDouble(getOrKeep(map, var3));
    print("Checking map: " + map + " - " + numbers + " -> " + result);
    functions = filter(functions, func(S f) -> bool {
      ai_checkNumberCalculationFunction1(f,
        numbers,
        result)
    });
    print("Remaining functions: " + functions);
  }
  
  ret ll(format("compute var " + quote(var3) + " from " + quote(var1) + " and " + quote(var2) + " using *", first(functions)));
}

Author comment

Began life as a copy of #1021864

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, whxojlpjdney

No comments. add comment

Snippet ID: #1021892
Snippet name: gazelle_proposeCalculationFunctions [dev.]
Eternal ID of this version: #1021892/7
Text MD5: 9ded9d421f0945a96551b730ba73f93c
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-03 00:31:45
Source code size: 1076 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 236 / 275
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)