/** * Attempt to map this Monad to the same type as the supplied Monoid (using mapToType on the monoid interface) * Then use Monoid to reduce values * * @param reducer Monoid to reduce values * @return Reduce result */ public final static <T> T foldLeftMapToType(Stream<T> stream,Monoid<T> reducer){ return reducer.mapReduce(stream); } /**
/** * Attempt to map this Monad to the same type as the supplied Monoid (using mapToType on the monoid interface) * Then use Monoid to reduce values * * @param reducer Monoid to reduce values * @return Reduce result */ public final <T> T foldLeftMapToType(Monoid<T> reducer){ return reducer.mapReduce(monad); } /**
/** * Attempt to map this Monad to the same type as the supplied Monoid (using mapToType on the monoid interface) * Then use Monoid to reduce values * * @param reducer Monoid to reduce values * @return Reduce result */ public final <R> R mapReduce(Monoid<R> reducer){ return reducer.mapReduce(monad); } /**
/** * Attempt to map this Monad to the same type as the supplied Monoid (using mapToType on the monoid interface) * Then use Monoid to reduce values * * @param reducer Monoid to reduce values * @return Reduce result */ public final static<T,R> R mapReduce(Stream<T> stream,Monoid<R> reducer){ return reducer.mapReduce(stream); } /**
/** * Attempt to map this Monad to the same type as the supplied Monoid (using mapToType on the monoid interface) * Then use Monoid to reduce values * * @param reducer Monoid to reduce values * @return Reduce result */ public final <T> T foldRightMapToType(Monoid<T> reducer){ return reducer.mapReduce(StreamUtils.reverse(monad)); } /**
/** * Attempt to map this Monad to the same type as the supplied Monoid (using mapToType on the monoid interface) * Then use Monoid to reduce values * * @param reducer Monoid to reduce values * @return Reduce result */ public final static <T> T foldRightMapToType(Stream<T> stream,Monoid<T> reducer){ return reducer.mapReduce(StreamUtils.reverse(stream)); } /**
return (List)m.mapReduce(stream);