diff --git a/src/main/java/org/cactoos/number/MaxOf.java b/src/main/java/org/cactoos/number/MaxOf.java index f28c41c20..5212dfb4d 100644 --- a/src/main/java/org/cactoos/number/MaxOf.java +++ b/src/main/java/org/cactoos/number/MaxOf.java @@ -25,7 +25,7 @@ import org.cactoos.iterable.IterableOf; import org.cactoos.iterable.Mapped; -import org.cactoos.scalar.Folded; +import org.cactoos.scalar.Reduced; /** * Find the greater among items. @@ -66,25 +66,21 @@ public MaxOf(final Number... src) { public MaxOf(final Iterable src) { super( new NumberOfScalars( - new Folded<>( - Long.MIN_VALUE, + new Reduced( Math::max, - new Mapped<>(Number::longValue, src) + new Mapped<>((Number n) -> n::longValue, src) ), - new Folded<>( - Integer.MIN_VALUE, + new Reduced( Math::max, - new Mapped<>(Number::intValue, src) + new Mapped<>((Number n) -> n::intValue, src) ), - new Folded<>( - -Float.MAX_VALUE, + new Reduced( Math::max, - new Mapped<>(Number::floatValue, src) + new Mapped<>((Number n) -> n::floatValue, src) ), - new Folded<>( - -Double.MAX_VALUE, + new Reduced( Math::max, - new Mapped<>(Number::doubleValue, src) + new Mapped<>((Number n) -> n::doubleValue, src) ) ) ); diff --git a/src/main/java/org/cactoos/number/MinOf.java b/src/main/java/org/cactoos/number/MinOf.java index f84853159..8d1b55fbb 100644 --- a/src/main/java/org/cactoos/number/MinOf.java +++ b/src/main/java/org/cactoos/number/MinOf.java @@ -25,7 +25,7 @@ import org.cactoos.iterable.IterableOf; import org.cactoos.iterable.Mapped; -import org.cactoos.scalar.Folded; +import org.cactoos.scalar.Reduced; /** * Find the smaller among items. @@ -66,25 +66,21 @@ public MinOf(final Number... src) { public MinOf(final Iterable src) { super( new NumberOfScalars( - new Folded<>( - Long.MAX_VALUE, + new Reduced( Math::min, - new Mapped<>(Number::longValue, src) + new Mapped<>((Number n) -> n::longValue, src) ), - new Folded<>( - Integer.MAX_VALUE, + new Reduced( Math::min, - new Mapped<>(Number::intValue, src) + new Mapped<>((Number n) -> n::intValue, src) ), - new Folded<>( - Float.MAX_VALUE, + new Reduced( Math::min, - new Mapped<>(Number::floatValue, src) + new Mapped<>((Number n) -> n::floatValue, src) ), - new Folded<>( - Double.MAX_VALUE, + new Reduced( Math::min, - new Mapped<>(Number::doubleValue, src) + new Mapped<>((Number n) -> n::doubleValue, src) ) ) );