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)

1  
static L<LongRange> chunks(long end, long chunkSize) {
2  
  ret chunks(0, end, chunkSize);
3  
}
4  
5  
static L<LongRange> chunks(long start, long end, long chunkSize) {
6  
  new L<LongRange> l;
7  
  long i = start;
8  
  while (i < end) {
9  
    l.add(LongRange(i, min(end, i+chunkSize)));
10  
    i += chunkSize;
11  
  }
12  
  ret l;
13  
}
14  
15  
static <A> LL<A> chunks(int chunkSize, L<A> l) {
16  
  ret listToChunks(chunkSize, l);
17  
}

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: 404 / 458
Version history: 6 change(s)
Referenced in: [show references]