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

12
LINES

< > BotCompany Repo | #1032924 // splitIntoRandomRangesOfApproximateLength

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

Transpiled version (4076L) is out of date.

static L<IntRange> splitIntoRandomRangesOfApproximateLength(double avgLength, IntRange base) {
  int i = base.start;
  new L<IntRange> out;
  int safety = 0;
  while (i < base.end && safety++ < l(base)) {
    double randVal = random(avgLength*2);
    int j = min(base.end, i+max(1, iround(randVal)));
    out.add(intRange(i, j));
    i = j;
  }
  ret out;
}

Author comment

Began life as a copy of #1032922

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1032924
Snippet name: splitIntoRandomRangesOfApproximateLength
Eternal ID of this version: #1032924/2
Text MD5: 0b0f4cdd3d6d70b8c3b99d7a3ab913b7
Author: stefan
Category: javac
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-10 23:20:40
Source code size: 368 bytes / 12 lines
Pitched / IR pitched: No / No
Views / Downloads: 71 / 105
Version history: 1 change(s)
Referenced in: [show references]