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

29
LINES

< > BotCompany Repo | #1000510 // FNonMarkedAsList

JavaX fragment (include)

static class FNonMarkedAsList extends FunctionImpl {
  public O process(Object _in) {
    String in = cast _in;
    L<int> m = getFindMarkers2(in);
    new L<S> list;
    for (int i = 0; i < m.size(); i += 2) {
      int from = i == 0 ? 0 : m.get(i-1);
      int to = i == m.size()-1 ? in.length() : m.get(i);
      if (to > from)
        list.add(in.substring(from, to));
    }
    ret list;
  }
  
  static L<int> getFindMarkers2(String s) {
    L<int> l = new ArrayList<Integer>();
    int i = 0;
    while (i < s.length()) {
      int j = s.indexOf("[[", i);
      if (j < 0) break;
      int k = s.indexOf("]]", j+2);
      if (k < 0) break;
      l.add(j);
      l.add(k+2);
      i = k+2;
    }
    return l;
  }
}

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: #1000510
Snippet name: FNonMarkedAsList
Eternal ID of this version: #1000510/1
Text MD5: fadac218cc7f2a984a301b746079b143
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2015-08-09 20:26:41
Source code size: 749 bytes / 29 lines
Pitched / IR pitched: No / Yes
Views / Downloads: 572 / 1283
Referenced in: #722 - IOIOI Processor (v15)
#738 - IOIOI Solver (v16, most recent one)
#1000513 - FJoin
#1000531 - FStringAsChars
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)