1 | static L<IntRange> findStreaks(L l, O pred) {
|
2 | new L<IntRange> out; |
3 | int i = 0, n = l(l); |
4 | while (i < n) {
|
5 | int j = i; |
6 | while (j < n && isTrue(callF(pred, l.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> findStreaks(O pred, L l) {
|
15 | ret findStreaks(l, pred); |
16 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1008769 |
| Snippet name: | findStreaks - find IntRanges of elements in a list where predicate is true |
| Eternal ID of this version: | #1008769/2 |
| Text MD5: | 4c3c2967e4d3a5bc6339077540cd1621 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2018-10-21 17:08:05 |
| Source code size: | 348 bytes / 16 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 806 / 848 |
| Version history: | 1 change(s) |
| Referenced in: | [show references] |