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

16
LINES

< > BotCompany Repo | #1026892 // intRangeChunks - returns L<IntRange>

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (2224L/14K).

static L<IntRange> intRangeChunks(int end, int chunkSize) {
  ret intRangeChunks(0, end, chunkSize);
}

static L<IntRange> intRangeChunks(int start, int end, int chunkSize) {
  new L<IntRange> l;
  int i = start;
  while (i < end) {
    l.add(IntRange(i, min(end, i+chunkSize)));
    i += chunkSize;
  }
  ret l;
}

// gratuitous convenience syntax for processing sound samples
static L<IntRange> intRangeChunks(short[] l, int chunkSize) { ret intRangeChunks(l(l), chunkSize); }

Author comment

Began life as a copy of #1020604

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1026892
Snippet name: intRangeChunks - returns L<IntRange>
Eternal ID of this version: #1026892/3
Text MD5: cd1a12db6d5b1bef2eb274f747cd3ef4
Transpilation MD5: 10072daa2924c20dc47ba2a95bfb59e7
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-02-02 14:55:38
Source code size: 493 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 162 / 230
Version history: 2 change(s)
Referenced in: [show references]