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

10
LINES

< > BotCompany Repo | #1012906 // tok_withoutOuterBrackets

JavaX fragment (include)

1  
static L<S> tok_withoutOuterBrackets(L<S> tok) {
2  
  if (!eq(get(tok, 1), "(") || !eq(nextToLast(tok), ")")) ret tok;
3  
  int level = 1;
4  
  for (int i = 3; i < l(tok)-2; i += 2) {
5  
    S t = get(tok, i);
6  
    if (eq(t, "(")) ++level;
7  
    else if (eq(t, ")")) if (--level == 0) ret tok;
8  
  }
9  
  ret level == 1 ? subList(tok, 2, l(tok)-2) : tok;
10  
}

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: #1012906
Snippet name: tok_withoutOuterBrackets
Eternal ID of this version: #1012906/2
Text MD5: 4e0d981884761c158ec92b9e4e6c511b
Author: stefan
Category: javax / parsing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-16 13:21:58
Source code size: 345 bytes / 10 lines
Pitched / IR pitched: No / No
Views / Downloads: 425 / 435
Version history: 1 change(s)
Referenced in: [show references]