T
- public interface Monoid<T> extends Semigroup<T>
Modifier and Type | Method and Description |
---|---|
static <T> Monoid<T> |
of(T zero,
java.util.function.BiFunction<T,T,T> combiner) |
static <T> Monoid<T> |
of(T zero,
java.util.function.Function<T,java.util.function.Function<T,T>> combiner) |
static <T> Monoid<T> |
of(T zero,
Semigroup<T> group) |
default T |
reduce(java.util.stream.Stream<T> toReduce) |
T |
zero()
An element that when provided as a parameter to the combiner with another value, results
in the other value being returned
e.g.
|
T zero()
0 + 1 = 1 0 is zero() 1 * 2 = 2 1 is zero() "" + "hello" = "hello" "" is zero()
static <T> Monoid<T> of(T zero, java.util.function.Function<T,java.util.function.Function<T,T>> combiner)
static <T> Monoid<T> of(T zero, java.util.function.BiFunction<T,T,T> combiner)