1 | static class LCombineTwoFunctions extends LearnerImpl {
|
2 | static boolean debug; |
3 | Function f, g; |
4 | |
5 | public void processInOut(Object in, Object out) {
|
6 | if (f != null) return; |
7 | List<Function> functions = allFunctions(); |
8 | |
9 | // simple version without really checking multiple candidates |
10 | for (Function f : functions) {
|
11 | Object o = tryProcess(f, in); |
12 | if (o != null) {
|
13 | if (debug) |
14 | debug("in=" + structure(in) + ", f=" + structure(f) + ", o=" + structure(o));
|
15 | for (Function g : functions) {
|
16 | Object x = tryProcess(g, o); |
17 | if (out.equals(x)) {
|
18 | if (debug) |
19 | debug("bingo! " + structure(g));
|
20 | this.f = f; |
21 | this.g = g; |
22 | return; |
23 | } |
24 | } |
25 | } |
26 | } |
27 | } |
28 | |
29 | public Object processIn(Object in) {
|
30 | return g.process(f.process(in)); |
31 | } |
32 | |
33 | static Object tryProcess(Function f, Object in) {
|
34 | try {
|
35 | return f.process(in); |
36 | } catch (Throwable e) {
|
37 | return null; |
38 | } |
39 | } |
40 | } |
Began life as a copy of #1000470
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: | #1000500 |
| Snippet name: | LCombineTwoFunctions (learner) |
| Eternal ID of this version: | #1000500/1 |
| Text MD5: | 3ac2d234ac18179bd14e8c0613853b6d |
| Author: | stefan |
| Category: | |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-08-09 18:21:14 |
| Source code size: | 1056 bytes / 40 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 913 / 1621 |
| Referenced in: | [show references] |