1 | // These end up inside the main class |
2 | |
3 | static class LBox extends LearnerImpl { |
4 | static boolean debug; |
5 | Learner middleLearner; |
6 | char topChar, bottomChar; |
7 | |
8 | *(Learner middleLearner) { |
9 | this.middleLearner = middleLearner; |
10 | } |
11 | |
12 | // An optimization, but a bit of a dangerous one: |
13 | /*public void forwardSecretExample(Object _in, Object _out) { |
14 | String in = (String) _in, out = (String) _out; |
15 | L<S> l = toLines(out); |
16 | String middle = l.get(2); |
17 | middleLearner.processInOut(in, middle); |
18 | }*/ |
19 | |
20 | public void tryAgain() { |
21 | middleLearner.tryAgain(); |
22 | } |
23 | |
24 | public void processInOut(Object _in, Object _out) { |
25 | String in = (String) _in, out = (String) _out; |
26 | L<S> l = toLines(out); |
27 | String middle = l.get(2); |
28 | middleLearner.processInOut(in, middle); |
29 | topChar = l.get(1).charAt(0); |
30 | bottomChar = l.get(3).charAt(0); |
31 | } |
32 | |
33 | public Object processIn(Object in) { |
34 | String middle = (String) middleLearner.processIn(in); |
35 | return "\n" + |
36 | main.repeat(topChar, middle.length()) + "\n" + |
37 | middle + "\n" + |
38 | main.repeat(bottomChar, middle.length()) + "\n"; |
39 | } |
40 | |
41 | public void toJava(Code code) { |
42 | todo(); |
43 | } |
44 | } |
45 | |
46 | static class LBox2 extends LearnerImpl { |
47 | static boolean debug; |
48 | Learner middleLearner; |
49 | char topChar, bottomChar, tlChar, trChar, blChar, brChar; |
50 | |
51 | *(Learner middleLearner) { |
52 | this.middleLearner = middleLearner; |
53 | } |
54 | |
55 | public void tryAgain() { |
56 | middleLearner.tryAgain(); |
57 | } |
58 | |
59 | public void processInOut(Object _in, Object _out) { |
60 | String in = (String) _in, out = (String) _out; |
61 | L<S> l = toLines(out); |
62 | String middle = l.get(2); |
63 | if (debug) |
64 | System.out.println("Forwarding to middle learner: " + quote(in) + " => " + quote(middle)); |
65 | middleLearner.processInOut(in, middle); |
66 | String top = l.get(1), bottom = l.get(3); |
67 | tlChar = top.charAt(0); |
68 | topChar = top.charAt(1); |
69 | trChar = top.charAt(top.length()-1); |
70 | blChar = bottom.charAt(0); |
71 | bottomChar = bottom.charAt(1); |
72 | brChar = bottom.charAt(bottom.length()-1); |
73 | } |
74 | |
75 | public Object processIn(Object in) { |
76 | String middle = (String) middleLearner.processIn(in); |
77 | return "\n" + |
78 | tlChar + main.repeat(topChar, middle.length()-2) + trChar + "\n" + |
79 | middle + "\n" + |
80 | blChar + main.repeat(bottomChar, middle.length()-2) + brChar + "\n"; |
81 | } |
82 | |
83 | public void toJava(Code code) { |
84 | todo(); |
85 | } |
86 | } |
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
ID | Author/Program | Comment | Date | |
---|---|---|---|---|
931 | #1000604 (pitcher) | 2015-08-20 15:28:24 | ||
930 | #1000610 | Edit suggestion: !636 !629 main { static Object androidContext; static String programID; public static void main(String[] args) throws Exception { // These end up inside the main class static class LBox extends LearnerImpl { static boolean debug; Learner middleLearner; char topChar, bottomChar; *(Learner middleLearner) { this.middleLearner = middleLearner; } // An optimization, but a bit of a dangerous one: /*public void forwardSecretExample(Object _in, Object _out) { String in = (String) _in, out = (String) _out; L<S> l = toLines(out); String middle = l.get(2); middleLearner.processInOut(in, middle); }*/ public void tryAgain() { middleLearner.tryAgain(); } public void processInOut(Object _in, Object _out) { String in = (String) _in, out = (String) _out; L<S> l = toLines(out); String middle = l.get(2); middleLearner.processInOut(in, middle); topChar = l.get(1).charAt(0); bottomChar = l.get(3).charAt(0); } public Object processIn(Object in) { String middle = (String) middleLearner.processIn(in); return "\n" + repeat(topChar, middle.length()) + "\n" + middle + "\n" + repeat(bottomChar, middle.length()) + "\n"; } static String repeat(char c, int n) { char[] chars = new char[n]; for (int i = 0; i < n; i++) chars[i] = c; return new String(chars); } public void toJava(Code code) { todo(); } } static class LBox2 extends LearnerImpl { static boolean debug; Learner middleLearner; char topChar, bottomChar, tlChar, trChar, blChar, brChar; *(Learner middleLearner) { this.middleLearner = middleLearner; } public void tryAgain() { middleLearner.tryAgain(); } public void processInOut(Object _in, Object _out) { String in = (String) _in, out = (String) _out; L<S> l = toLines(out); String middle = l.get(2); if (debug) System.out.println("Forwarding to middle learner: " + quote(in) + " => " + quote(middle)); middleLearner.processInOut(in, middle); String top = l.get(1), bottom = l.get(3); tlChar = top.charAt(0); topChar = top.charAt(1); trChar = top.charAt(top.length()-1); blChar = bottom.charAt(0); bottomChar = bottom.charAt(1); brChar = bottom.charAt(bottom.length()-1); } public Object processIn(Object in) { String middle = (String) middleLearner.processIn(in); return "\n" + tlChar + repeat(topChar, middle.length()-2) + trChar + "\n" + middle + "\n" + blChar + repeat(bottomChar, middle.length()-2) + brChar + "\n"; } static String repeat(char c, int n) { char[] chars = new char[n]; for (int i = 0; i < n; i++) chars[i] = c; return new String(chars); } public void toJava(Code code) { todo(); } } }} | 2015-08-20 05:39:36 | delete |
Snippet ID: | #1000382 |
Snippet name: | Box learners |
Eternal ID of this version: | #1000382/1 |
Text MD5: | fba1c0b6fbb6fb06ec5e4beeab9e0533 |
Author: | stefan |
Category: | |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-10-17 01:20:45 |
Source code size: | 2468 bytes / 86 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 1151 / 3024 |
Referenced in: | [show references] |