diff --git a/src/main/java/org/cactoos/scalar/Reduced.java b/src/main/java/org/cactoos/scalar/Reduced.java index 4697b658b..5e04825de 100644 --- a/src/main/java/org/cactoos/scalar/Reduced.java +++ b/src/main/java/org/cactoos/scalar/Reduced.java @@ -97,6 +97,19 @@ public Reduced( this(reduce, new Mapped<>(Constant::new, values)); } + /** + * Ctor. + * @param values Values to be wrapped as scalars + * @param reduce Reducing function + * @since 0.55.0 + */ + public Reduced( + final Iterable values, + final BiFunc reduce + ) { + this(reduce, new Mapped<>(Constant::new, values)); + } + /** * Ctor. * @param reduce Reducing function diff --git a/src/test/java/org/cactoos/scalar/ReducedTest.java b/src/test/java/org/cactoos/scalar/ReducedTest.java index 487d69366..d7340189b 100644 --- a/src/test/java/org/cactoos/scalar/ReducedTest.java +++ b/src/test/java/org/cactoos/scalar/ReducedTest.java @@ -97,6 +97,21 @@ public void lastAtIterable() { ).affirm(); } + @Test + public void lastAtIterableOfValues() { + final Character one = 'A'; + final Character two = 'B'; + final Character three = 'O'; + new Assertion<>( + "Must find the last character", + new Reduced<>( + new IterableOf<>(one, two, three), + (first, last) -> last + ), + new HasValue<>(three) + ).affirm(); + } + @Test public void constructedFromVarargs() { final String one = "One";