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

29
LINES

< > BotCompany Repo | #1017544 // splitAtTokens

JavaX fragment (include)

1  
static L<S> splitAtTokens(S s, LS tokens) {
2  
  ret splitAtTokens(javaTok(s), tokens);
3  
}
4  
5  
static L<S> splitAtTokens(L<S> tok, LS tokens) {
6  
  new L<S> l;
7  
  int i = 0;
8  
  while (i < l(tok)) {
9  
    int j = indexOfSubList(tok, tokens, i);
10  
    if (i >= l(tok)) break;
11  
    if (j < 0) j = l(tok);
12  
    l.add(trimJoin(tok.subList(i, j)));
13  
    i = j+l(tokens);
14  
  }
15  
  ret l;
16  
}
17  
18  
static L<S> splitAtTokens(L<S> tok, S... tokens) {
19  
  new L<S> l;
20  
  int i = 0;
21  
  while (i < l(tok)) {
22  
    int j = indexOfSubList(tok, tokens, i);
23  
    if (i >= l(tok)) break;
24  
    if (j < 0) j = l(tok);
25  
    l.add(trimJoin(tok.subList(i, j)));
26  
    i = j+l(tokens);
27  
  }
28  
  ret l;
29  
}

Author comment

Began life as a copy of #1011989

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1017544
Snippet name: splitAtTokens
Eternal ID of this version: #1017544/3
Text MD5: acd1b1307e488e0692e664d6b3380989
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-01-03 19:57:39
Source code size: 666 bytes / 29 lines
Pitched / IR pitched: No / No
Views / Downloads: 461 / 485
Version history: 2 change(s)
Referenced in: [show references]