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

16
LINES

< > BotCompany Repo | #1035606 // genericStreaks

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

Transpiled version (9275L) is out of date.

1  
static L<IntRange> lambdaMapLike genericStreaks(IIntPred pred, int n) {
2  
  new L<IntRange> out;
3  
  int i = 0;
4  
  while (i < n) {
5  
    int j = i;
6  
    while (j < n && pred.get(j)) ++j;
7  
    if (j > i)
8  
      out.add(intRange(i, j));
9  
    i = j+1;
10  
  }
11  
  ret out;
12  
}
13  
14  
static L<IntRange> lambdaMapLike genericStreaks(int n, IIntPred pred) {
15  
  ret genericStreaks(pred, n);
16  
}

Author comment

Began life as a copy of #1019037

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035606
Snippet name: genericStreaks
Eternal ID of this version: #1035606/2
Text MD5: 460868082754ab65532217f55ad760e8
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-06-26 18:37:44
Source code size: 371 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 134 / 164
Version history: 1 change(s)
Referenced in: [show references]