Created
June 29, 2025 02:24
-
-
Save rokon12/eef55a38d98ecf00c099cae3c76ad94e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<Integer> runningMax = values.stream() | |
.gather(Gatherers.scan( | |
() -> Integer.MIN_VALUE, | |
Integer::max | |
)) | |
.toList(); | |
System.out.println("Running maximum: " + runningMax); | |
// Output: [-2147483648, 1, 5, 5, 8, 8, 9, 9, 9, 9] | |
// ↑ initial ↑ 5>1 ↑ 8>5 ↑ 9>8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment