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

15
LINES

< > BotCompany Repo | #1011447 // dropCertainPunctuationAtEnd

JavaX fragment (include)

1  
static L<S> dropCertainPunctuationAtEnd(L<S> tok, S charsToDrop) {
2  
  tok = cloneList(tok);
3  
  for (int i = tok.size()-2; i > 0; i -= 2) {
4  
    S t = tok.get(i);
5  
    if (t.length() == 1 && charsToDrop.contains(t)) {
6  
      tok.remove(i+1);
7  
      tok.remove(i);
8  
    } else break;
9  
  }
10  
  return tok;
11  
}
12  
13  
static S dropCertainPunctuationAtEnd(S s, S chars) {
14  
  ret join(dropCertainPunctuationAtEnd(nlTok(s), chars));
15  
}

Author comment

Began life as a copy of #1008344

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: #1011447
Snippet name: dropCertainPunctuationAtEnd
Eternal ID of this version: #1011447/1
Text MD5: 53cf9c7f4c54461b27c6c296eea86a43
Author: stefan
Category:
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-10-29 16:48:16
Source code size: 422 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 471 / 525
Referenced in: [show references]