sclass C { char c; bool output; *() {} *(char *c, bool *output) {} public bool equals(O o) { ret o instanceof C && c == ((C) o).c && output == ((C) o).output; } public int hashCode() { ret (int) c + (output ? 0x1000 : 0); } } static L<C> poemToC(S poemID) { new L<C> l; for (E e : parsePoem(poemID)) if (e.q != null) addC(l, e.q + "\n", false); else if (e.a != null) addC(l, e.a + "\n", true); ret l; } static void addC(L<C> script, S s, bool output) { for (char c : asChars(s)) script.add(new C(c, output)); } static L<E> poemFromC(L<C> script) { new L<E> l; int i = 0; while (i < l(script)) { new E e; int j = poemFromC_scan(script, i, false); if (j > i) e.q = poemFromC_join(script, i, j); else { j = poemFromC_scan(script, i, true); assertTrue(j > i); e.a = poemFromC_join(script, i, j); } l.add(e); i = j; } ret l; } static int poemFromC_scan(L<C> script, int i, bool output) { while (i < l(script) && script.get(i).output == output) ++i; ret i; } static S poemFromC_join(L<C> script, int i, int j) { new StringBuilder buf; for (; i < j; i++) buf.append(script.get(i).c); ret str(buf); }
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: | #1003283 |
Snippet name: | class C (character + input/output flag) with functions |
Eternal ID of this version: | #1003283/1 |
Text MD5: | 7ed6da074296a2baa5d1c6f197614f4c |
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-15 00:19:55 |
Source code size: | 1304 bytes / 62 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 529 / 737 |
Referenced in: | [show references] |