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

41
LINES

< > BotCompany Repo | #1000459 // LFixWhitespace (works)

JavaX source code - run with: x30.jar

// These end up inside the main class

static class LFixWhitespace extends LearnerImpl {
  static boolean debug;
  Learner base;
  String s;
  
  *(Learner *base) {}
  
  public void tryAgain() {
    base.tryAgain();
  }
  
  public void processInOut(Object _in, Object _out) {
    String in = (String) _in, out = (String) _out;
    int i = count(in), j = count(out);
    in = in.substring(i);
    s = out.substring(0, j);
    out = out.substring(j);
  if (debug)
      System.out.println("LFixWhitespace: Feeding to input learner: " + in + " => " + out);
    base.processInOut(in, out);
  }
  
  public Object processIn(Object _in) {
    String in = (String) _in;
    int i = count(in);
    in = in.substring(i);
    in = (String) base.processIn(in);
    in = s + in;
    return in;
  }

  int count(String s) {
    int I = 0;
    while (I < s.length () && "\r\n\t ".indexOf(s.charAt(I)) >= 0)
      ++I;
    return I;
  }

}

Author comment

Began life as a copy of #1000387

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: #1000459
Snippet name: LFixWhitespace (works)
Eternal ID of this version: #1000459/1
Text MD5: c1d05958a7f866bf16f2164493f74129
Author: stefan
Category:
Type: JavaX source code
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-08 03:20:55
Source code size: 968 bytes / 41 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 568 / 1946
Referenced in: [show references]