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

16
LINES

< > BotCompany Repo | #1018224 // findNonStreaks - find IntRanges of elements in a list where predicate is false

JavaX fragment (include)

1  
static L<IntRange> findNonStreaks(L l, O pred) {
2  
  new L<IntRange> out;
3  
  int i = 0, n = l(l);
4  
  while (i < n) {
5  
    int j = i;
6  
    while (j < n && !isTrue(callF(pred, l.get(j)))) ++j;
7  
    if (j > i)
8  
      out.add(intRange(i, j));
9  
    i = j+1;
10  
  }
11  
  ret out;
12  
}
13  
14  
static L<IntRange> findNonStreaks(O pred, L l) {
15  
  ret findNonStreaks(l, pred);
16  
}

Author comment

Began life as a copy of #1008769

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1018224
Snippet name: findNonStreaks - find IntRanges of elements in a list where predicate is false
Eternal ID of this version: #1018224/2
Text MD5: a76d4d68afd28c69c6b873cfb262188f
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-10-21 17:09:13
Source code size: 358 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 341 / 370
Version history: 1 change(s)
Referenced in: [show references]