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

!7

sS text = [[
The playing field has a size of 8 times 8.
The columns are labelled from A (from the left).
The rows are labelled from 1 (from the top).
What is the label of the third column from the left? => C
]];

static Map<S, O> enablerMap = litorderedmap(
  "The columns are labelled from A (from the left)", f columnsLabelledFromA);

static S columnsLabelledFromA(S s) {
  new Matches m;
  if "What is the label of the * column from the left?" {
    Int i = ai_indexToNr($1);
    if (i != null)
      ret strCharPlus('A', i-1);
  }
  null;
}

static new LinkedHashSet enabledFunctions;

p {
  L<S> sentences = sentences(text);
  printAsciiHeading("Sentences");
  pnl(sentences);
  for (S s : sentences)
    addAll(enabledFunctions, lookupAllByNLMatch(enablerMap, s));
  print("Functions: " + enabledFunctions);
  
  for (S s : sentences) {
    L<S> l = splitAtDoubleArrow(s);
    S expected = null;
    if (l(l) == 2) {
      s = first(l);
      expected = second(l);
    }
    L<S> out = pcallFunctions_collectNemptyStrings(enabledFunctions, s);
    printAll(out);
    if (expected != null)
      print(cic(out, expected) ? "OK" : "Not OK");
  }
}

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: 457 / 1128
Version history: 11 change(s)
Referenced in: [show references]