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

41
LINES

< > BotCompany Repo | #1000485 // LFixedPositions

JavaX fragment (include)

// for stuff like #1000349

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

  public void processInOut(Object _in, Object _out) {
    // Only looks at out... funny, eh?
    
    String out = cast _out;
    for (int i = 0; i < out.length(); i++) {
      String s = map.get(i);
      String c = out.substring(i, i+1);
      if (s == null)
        map.put(i, c);
      else if (s.equals("")) {
      } else if (!s.equals(c))
        map.put(i, ""); // TILT
    }
    
    for (int i : map.keySet())
      if (i >= out.length())
        map.put(i, "");
  }
  
  public Object processIn(Object _in) {
    String in = cast _in;
    new List<String> l;
    for (int i = 0; i < in.length(); i++)
      l.add(in.substring(i, i+1));
    for (int i : map.keySet()) {
      String s = map.get(i);
      if (!s.equals("")) {
        while (i >= l.size())
          l.add(" ");
        l.set(i, s);
      }
    }
    return join("", l);
  }
}

Author comment

Began life as a copy of #1000481

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: #1000485
Snippet name: LFixedPositions
Eternal ID of this version: #1000485/1
Text MD5: e076c3c0cc2ee0fb596b6b3a745451da
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-09 02:51:14
Source code size: 1057 bytes / 41 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 666 / 1587
Referenced in: [show references]