sclass SuperPrecise { sclass C { char c; bool output; *() {} *(char *c, bool *output) {} } S poemID; new L<C> script; int i = 0; bool fail; new StringBuilder out; *(S *poemID) { for (E e : parsePoem(poemID)) { if (e.q != null) addInput(e.q + "\n"); else if (e.a != null) addOutput(e.a + "\n"); } loop(); } // probably remove this void loop() { printOut(); S line; while ((line = readLine()) != null) { for (char c : chars(line + "\n")) onIncomingCharacter(c); printOut(); } } void addOutput(S text) { for (char c : asChars(text)) script.add(new C(c, true)); } void addInput(S text) { for (char c : asChars(text)) script.add(new C(c, false)); } void onIncomingCharacter(char c) { if (fail || get(script, i) == null) charPut('?'); else { C x = get(script, i); assertFalse(x.output); if (c == x.c) { ++i; printOut(); } else { fail = true; charPut('?'); } } } void printOut() { while (!fail && get(script, i) != null && get(script, i).output) charPut(get(script, i++).c); //charPut_flush(); } void charPut(char c) { out.append(c); } }
Began life as a copy of #1003257
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: | #1003274 |
Snippet name: | "Super Precise" Engine As Class |
Eternal ID of this version: | #1003274/1 |
Text MD5: | d4725039e614212ce70c97014f206e0f |
Author: | stefan |
Category: | javax / talking robots |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-06-13 01:01:18 |
Source code size: | 1387 bytes / 73 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 587 / 838 |
Referenced in: | [show references] |