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

14
LINES

< > BotCompany Repo | #1015445 // chunksOf

JavaX fragment (include)

static <A> LL<A> chunksOf(Collection<A> c, int n) {
  new LL<A> out;
  Iterator<A> it = iterator(c);
  L<A> l = new L(n);
  while (it.hasNext()) {
    l.add(it.next());
    if (l(l) >= n) {
      out.add(l);
      l = new L(n);
    }
  }
  if (nempty(l)) out.add(l);
  ret out;
}

Author comment

Began life as a copy of #1011921

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: #1015445
Snippet name: chunksOf
Eternal ID of this version: #1015445/1
Text MD5: bdacaa1228c328ab61bc629ddbc926b4
Author: stefan
Category: javax / collections
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-14 01:31:21
Source code size: 292 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 426 / 452
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)