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

29
LINES

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

JavaX fragment (include)

// 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;
  }
}

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: 896 / 1814
Referenced in: [show references]