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

16
LINES

< > BotCompany Repo | #1023224 // streaksAndNonStreaks - predicate may also return null

JavaX fragment (include)

static <A> LL<A> mapLike streaksAndNonStreaks(O pred, L<A> l) {
  new LL<A> out;
  int start = 0;
  Bool last = null;
  for i over l: {
    Bool result = (Bool) callF(pred, l.get(i));
    if (last != null && result != null && neq(result, last)) {
      out.add(subList(l, start, i));
      start = i;
    }
    if (result != null) last = result;
  }
  if (start < l(l))
    out.add(subList(l, start));
  ret out;
}

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1023224
Snippet name: streaksAndNonStreaks - predicate may also return null
Eternal ID of this version: #1023224/7
Text MD5: c245dcf48cccd0cd9f578e4bf45eff89
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-05-17 00:01:48
Source code size: 429 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 252 / 295
Version history: 6 change(s)
Referenced in: [show references]