Class ReduceRight<A>

  • Type Parameters:
    A - The input Iterable element type, as well as the accumulation type
    All Implemented Interfaces:
    Fn1<Fn2<? super A,​? super A,​? extends A>,​Fn1<java.lang.Iterable<A>,​Maybe<A>>>, Fn2<Fn2<? super A,​? super A,​? extends A>,​java.lang.Iterable<A>,​Maybe<A>>, Applicative<Fn1<java.lang.Iterable<A>,​Maybe<A>>,​Fn1<Fn2<? super A,​? super A,​? extends A>,​?>>, Cartesian<Fn2<? super A,​? super A,​? extends A>,​Fn1<java.lang.Iterable<A>,​Maybe<A>>,​Fn1<?,​?>>, Cocartesian<Fn2<? super A,​? super A,​? extends A>,​Fn1<java.lang.Iterable<A>,​Maybe<A>>,​Fn1<?,​?>>, Contravariant<Fn2<? super A,​? super A,​? extends A>,​Profunctor<?,​Fn1<java.lang.Iterable<A>,​Maybe<A>>,​Fn1<?,​?>>>, Functor<Fn1<java.lang.Iterable<A>,​Maybe<A>>,​Fn1<Fn2<? super A,​? super A,​? extends A>,​?>>, Profunctor<Fn2<? super A,​? super A,​? extends A>,​Fn1<java.lang.Iterable<A>,​Maybe<A>>,​Fn1<?,​?>>, Monad<Fn1<java.lang.Iterable<A>,​Maybe<A>>,​Fn1<Fn2<? super A,​? super A,​? extends A>,​?>>, MonadReader<Fn2<? super A,​? super A,​? extends A>,​Fn1<java.lang.Iterable<A>,​Maybe<A>>,​Fn1<Fn2<? super A,​? super A,​? extends A>,​?>>, MonadRec<Fn1<java.lang.Iterable<A>,​Maybe<A>>,​Fn1<Fn2<? super A,​? super A,​? extends A>,​?>>, MonadWriter<Fn2<? super A,​? super A,​? extends A>,​Fn1<java.lang.Iterable<A>,​Maybe<A>>,​Fn1<Fn2<? super A,​? super A,​? extends A>,​?>>

    public final class ReduceRight<A>
    extends java.lang.Object
    implements Fn2<Fn2<? super A,​? super A,​? extends A>,​java.lang.Iterable<A>,​Maybe<A>>
    Given an Iterable<A> and a Fn2<A, A, A>, iteratively accumulate over the Iterable, returning Maybe<A>. If the Iterable is empty, the result is Maybe.nothing(); otherwise, the result is wrapped in Maybe.just(A). For this reason, null accumulation results are considered erroneous and will throw.

    This function is isomorphic to a right fold over the Iterable where the tail element is the starting accumulation value and the result is lifted into Maybe.

    See Also:
    ReduceLeft, FoldRight
    • Field Detail

      • INSTANCE

        private static final ReduceRight<?> INSTANCE
    • Constructor Detail

      • ReduceRight

        private ReduceRight()
    • Method Detail

      • checkedApply

        public final Maybe<A> checkedApply​(Fn2<? super A,​? super A,​? extends A> fn,
                                           java.lang.Iterable<A> as)
        Specified by:
        checkedApply in interface Fn2<Fn2<? super A,​? super A,​? extends A>,​java.lang.Iterable<A>,​Maybe<A>>
      • reduceRight

        public static <A> ReduceRight<A> reduceRight()
      • reduceRight

        public static <A> Fn1<java.lang.Iterable<A>,​Maybe<A>> reduceRight​(Fn2<? super A,​? super A,​? extends A> fn)
      • reduceRight

        public static <A> Maybe<A> reduceRight​(Fn2<? super A,​? super A,​? extends A> fn,
                                               java.lang.Iterable<A> as)