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)

static L<IntRange> findNonStreaks(L l, O pred) {
  new L<IntRange> out;
  int i = 0, n = l(l);
  while (i < n) {
    int j = i;
    while (j < n && !isTrue(callF(pred, l.get(j)))) ++j;
    if (j > i)
      out.add(intRange(i, j));
    i = j+1;
  }
  ret out;
}

static L<IntRange> findNonStreaks(O pred, L l) {
  ret findNonStreaks(l, pred);
}

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: 340 / 368
Version history: 1 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1018225 - findCodeTokenNonStreaks - find IntRanges of code tokens in a CNC list where predicate is false; ranges are C to N