Libraryless. Click here for Pure Java version (4685L/26K).
1 | static <A> LPair<IntRange, A> streaksOfRepeatingElements(L<A> l) { |
2 | new LPair<IntRange, A> out; |
3 | int i = 0, n = l(l); |
4 | while (i < n) { |
5 | A a = l.get(i); |
6 | int j = i+1; |
7 | while (j < n && eq(a, l.get(j))) ++j; |
8 | out.add(pair(intRange(i, j), a)); |
9 | i = j; |
10 | } |
11 | ret out; |
12 | } |
Began life as a copy of #1011014
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1033726 |
Snippet name: | streaksOfRepeatingElements |
Eternal ID of this version: | #1033726/3 |
Text MD5: | d567132f1da3263e4ca6535c5a5334e7 |
Transpilation MD5: | b502380efcbbb2e32fd0a311a7e9cf2f |
Author: | stefan |
Category: | javax |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-12-30 22:01:13 |
Source code size: | 293 bytes / 12 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 174 / 223 |
Version history: | 2 change(s) |
Referenced in: | [show references] |