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

15
LINES

< > BotCompany Repo | #1008803 // xtok_joinBrackets2

JavaX fragment (include)

static L xtok_joinBrackets2(L tok) {
  new L t;
  Map<Int, Int> map = getBracketMap(tok);
  for (int i = 0; i < l(tok); i++) {
    Int dest = map.get(i);
    if (dest != null && !(i == 1 && dest == 5 && l(tok) == 7)) {
      t.addAll(subList(tok, i, i+2)); // bracket plus N
      t.add(cncAddFirstAndLast(subList(tok, i+2, dest-1)));
      t.addAll(subList(tok, dest-1, dest+1)); // N plus bracket
      i = dest;
    } else
      t.add(tok.get(i));
  }
  ret t;
}

Author comment

Began life as a copy of #1008799

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1008803
Snippet name: xtok_joinBrackets2
Eternal ID of this version: #1008803/8
Text MD5: dcf0ddda67dd622ab5efbe5ed041616e
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-06-09 02:39:37
Source code size: 479 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 558 / 603
Version history: 7 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1008808 - xtok_joinBrackets3