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

9
LINES

< > BotCompany Repo | #1029482 // intersectIntRanges

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

Transpiled version (2628L) is out of date.

static IntRange intersectIntRanges(IntRange a, IntRange b) {
  int start = max(a.start, b.start);
  int end = min(a.end, b.end);
  ret start <= end ? IntRange(start, end) : null;
}

static L<IntRange> intersectIntRanges(Iterable<IntRange> l, IntRange b) {
  ret map(l, r -> intersectIntRanges(r, b));
}

Author comment

Began life as a copy of #1028623

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: #1029482
Snippet name: intersectIntRanges
Eternal ID of this version: #1029482/4
Text MD5: 81b7a1cfe4c040ecb92a266432adfa4d
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-30 00:59:23
Source code size: 310 bytes / 9 lines
Pitched / IR pitched: No / No
Views / Downloads: 256 / 319
Version history: 3 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1029483 - intRangesOverlap - is also true when intersection has length 0