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

16
LINES

< > BotCompany Repo | #1005100 // groupNonEmpty

JavaX fragment (include)

// isSep: func(A) -> bool
static <A> L<L<A>> groupNonEmpty(L<A> l, O isSep) {
  new L<L<A>> out;
  int j = 0;
  for (int i = 0; i < l(l); i++) {
    bool sep = isTrue(callF(isSep, l.get(i)));
    if (sep) {
      if (i > j)
        out.add(newSubList(l, j, i));
      j = i+1;
    }
  }
  if (l(l) > j)
    out.add(newSubList(l, j));
  ret out;
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1005100
Snippet name: groupNonEmpty
Eternal ID of this version: #1005100/1
Text MD5: d85e18fe996fd306f0aa4425ec6ac3b1
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2016-10-16 17:20:37
Source code size: 361 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 489 / 492
Referenced in: [show references]