/** * Reverse a Stream * * @param stream Stream to reverse * @return Reversed stream */ public static <U> Stream<U> reverse(Stream<U> stream){ return StreamUtils.reverse(stream); } /**
/** * * * @param reducer Use supplied Monoid to reduce values starting via foldRight * @return Reduced result */ public final T foldRight(Monoid<T> reducer){ return reducer.reduce(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 <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)); } /**
/** * * * @param reducer Use supplied Monoid to reduce values starting via foldRight * @return Reduced result */ public final static <T> T foldRight(Stream<T> stream,Monoid<T> reducer){ return reducer.reduce(StreamUtils.reverse(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 static <T> T foldRightMapToType(Stream<T> stream,Monoid<T> reducer){ return reducer.mapReduce(StreamUtils.reverse(stream)); } /**
/** * * * @param reducer Use supplied Monoid to reduce values starting via foldRight * @return Reduced result */ public final static <T> T foldRight(Stream<T> stream,Monoid<T> reducer){ return reducer.reduce(StreamUtils.reverse(stream)); } /**
public SequenceM<T> reverse(){ return new SequenceM(StreamUtils.reverse(monad)); }
public SequenceM<T> reverse(){ if(reversable.isPresent()){ reversable.ifPresent(r->r.invert()); return this; } return StreamUtils.sequenceM(StreamUtils.reverse(stream),reversable); }