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  old transpilations   

Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, 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: 327 / 376
Version history: 6 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1026892 - intRangeChunks - returns L<IntRange>