// 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" +
main.repeat(topChar, middle.length()) + "\n" +
middle + "\n" +
main.repeat(bottomChar, middle.length()) + "\n";
}
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 + main.repeat(topChar, middle.length()-2) + trChar + "\n" +
middle + "\n" +
blChar + main.repeat(bottomChar, middle.length()-2) + brChar + "\n";
}
public void toJava(Code code) {
todo();
}
}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
2 comment(s) hidden. show
| 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: | 1987 / 3788 |
| Referenced in: | [show references] |