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

16
LINES

< > BotCompany Repo | #1012734 // splitStringAtIndices

JavaX fragment (include)

1  
// assumes indices are sorted
2  
static L<S> splitStringAtIndices(S s, L<Int> indices) {
3  
  Iterator<Int> it = indices.iterator();
4  
  new L<S> parts;
5  
  int i = 0;
6  
  while true {
7  
    if (!it.hasNext()) {
8  
      parts.add(substring(s, i));
9  
      break;
10  
    }
11  
    int j = it.next();
12  
    parts.add(substring(s, i, j));
13  
    i = j;
14  
  }
15  
  ret parts;
16  
}

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: #1012734
Snippet name: splitStringAtIndices
Eternal ID of this version: #1012734/2
Text MD5: 0019f91c1068c8dd38484f40a9598a3f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-11 15:23:28
Source code size: 353 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 387 / 403
Version history: 1 change(s)
Referenced in: [show references]