Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

29
LINES

< > BotCompany Repo | #1000486 // LMap (developing)

JavaX fragment (include)

1  
// for stuff like #1000351
2  
3  
static class LMap extends LearnerImpl {
4  
  static boolean debug;
5  
  Map<String, String> map = new TreeMap<String, String>();
6  
7  
  public void processInOut(Object _in, Object _out) {
8  
    List<String> in = cast _in;
9  
    List<String> out = cast _out;
10  
    
11  
    if (in.size() != out.size()) fail();
12  
    
13  
    for (int i = 0; i < in.size(); i++) {
14  
      String a = in.get(i), b = out.get(i);
15  
      if (!a.equals(b))
16  
        map.put(a, b);
17  
    }
18  
  }
19  
  
20  
  public Object processIn(Object _in) {
21  
    List<String> in = cast _in;
22  
    new List<String> out;
23  
    for (int i = 0; i < in.size(); i++) {
24  
      String a = in.get(i), b = map.get(a);
25  
      out.add(b != null ? b : a);
26  
    }
27  
    return out;
28  
  }
29  
}

Author comment

Began life as a copy of #1000485

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

Comments [hide]

ID Author/Program Comment Date
630 #1000610 Edit suggestion:
!636
!629

main {
static Object androidContext;
static String programID;

public static void main(String[] args) throws Exception {
// for stuff like #1000351

static class LMap extends LearnerImpl {
static boolean debug;
Map<String, String> map = new TreeMap<String, String>();

public void processInOut(Object _in, Object _out) {
List<String> in = cast _in;
List<String> out = cast _out;

if (in.size() != out.size()) fail();

for (int i = 0; i < in.size(); i++) {
String a = in.get(i), b = out.get(i);
if (!a.equals(b))
map.put(a, b);
}
}

public Object processIn(Object _in) {
List<String> in = cast _in;
new List<String> out;
for (int i = 0; i < in.size(); i++) {
String a = in.get(i), b = map.get(a);
out.add(b != null ? b : a);
}
return out;
}
}
}}
2015-08-19 01:20:16  delete 
628 #1000604 (pitcher) 2015-08-18 00:07:22

add comment

Snippet ID: #1000486
Snippet name: LMap (developing)
Eternal ID of this version: #1000486/1
Text MD5: 7b1f65e8bdf21e6e9bc399283ec5d8d7
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-09 02:58:41
Source code size: 742 bytes / 29 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 897 / 1815
Referenced in: [show references]