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

45
LINES

< > BotCompany Repo | #1012503 // Array logic engine [dev.]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (2258L/15K).

1  
!7
2  
3  
sS text = [[
4  
The playing field has a size of 8 times 8.
5  
The columns are labelled from A (from the left).
6  
The rows are labelled from 1 (from the top).
7  
What is the label of the third column from the left? => C
8  
]];
9  
10  
static Map<S, O> enablerMap = litorderedmap(
11  
  "The columns are labelled from A (from the left)", f columnsLabelledFromA);
12  
13  
static S columnsLabelledFromA(S s) {
14  
  new Matches m;
15  
  if "What is the label of the * column from the left?" {
16  
    Int i = ai_indexToNr($1);
17  
    if (i != null)
18  
      ret strCharPlus('A', i-1);
19  
  }
20  
  null;
21  
}
22  
23  
static new LinkedHashSet enabledFunctions;
24  
25  
p {
26  
  L<S> sentences = sentences(text);
27  
  printAsciiHeading("Sentences");
28  
  pnl(sentences);
29  
  for (S s : sentences)
30  
    addAll(enabledFunctions, lookupAllByNLMatch(enablerMap, s));
31  
  print("Functions: " + enabledFunctions);
32  
  
33  
  for (S s : sentences) {
34  
    L<S> l = splitAtDoubleArrow(s);
35  
    S expected = null;
36  
    if (l(l) == 2) {
37  
      s = first(l);
38  
      expected = second(l);
39  
    }
40  
    L<S> out = pcallFunctions_collectNemptyStrings(enabledFunctions, s);
41  
    printAll(out);
42  
    if (expected != null)
43  
      print(cic(out, expected) ? "OK" : "Not OK");
44  
  }
45  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1012503
Snippet name: Array logic engine [dev.]
Eternal ID of this version: #1012503/12
Text MD5: bf4052d2d53d44ba52cedf1ed02457ea
Transpilation MD5: ad1f205a2aea5d1fb031ee767d4c5334
Author: stefan
Category: javax / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-05 16:08:10
Source code size: 1199 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 325 / 792
Version history: 11 change(s)
Referenced in: [show references]