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

17
LINES

< > BotCompany Repo | #1020604 - chunks - returns L<LongRange>. also synonym of listToChunks

JavaX fragment (include)

static L<LongRange> chunks(long end, long chunkSize) {
  ret chunks(0, end, chunkSize);
}

static L<LongRange> chunks(long start, long end, long chunkSize) {
  new L<LongRange> l;
  long i = start;
  while (i < end) {
    l.add(LongRange(i, min(end, i+chunkSize)));
    i += chunkSize;
  }
  ret l;
}

static <A> LL<A> chunks(int chunkSize, L<A> l) {
  ret listToChunks(chunkSize, l);
}

download  show line numbers  debug dex   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pzhvpgtvlbxg, tvejysmllsmz, xrpafgyirdlv

No comments. add comment

Snippet ID: #1020604
Snippet name: chunks - returns L<LongRange>. also synonym of listToChunks
Eternal ID of this version: #1020604/7
Text MD5: 5e5cc095ef6215a186409151c96e162a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-11 19:14:14
Source code size: 402 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 131 / 139
Version history: 6 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1020604 & http://1020604.tinybrain.de