Skip to content

Commit 1320748

Browse files
Code refactor for AbsoluteMin improvements (TheAlgorithms#3031)
Fix TheAlgorithms#3030 Co-authored-by: Yang Libin <szuyanglb@outlook.com>
1 parent c8b0a20 commit 1320748

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/main/java/com/thealgorithms/maths/AbsoluteMin.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ public static int getMinValue(int... numbers) {
2121

2222
Arrays.stream(numbers)
2323
.skip(1)
24-
.forEach(number -> {
25-
if (Math.abs(number) < Math.abs(absMinWrapper.value)) {
26-
absMinWrapper.value = number;
27-
}
28-
});
24+
.filter(number -> Math.abs(number) < Math.abs(absMinWrapper.value))
25+
.forEach(number -> absMinWrapper.value = number);
2926

3027
return absMinWrapper.value;
3128
}

0 commit comments

Comments
 (0)