Class ReduceRight<A>
- java.lang.Object
-
- com.jnape.palatable.lambda.functions.builtin.fn2.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
and aIterable
<A>
, iteratively accumulate over theFn2
<A, A, A>Iterable
, returning
. If theMaybe
<A>Iterable
is empty, the result isMaybe.nothing()
; otherwise, the result is wrapped inMaybe.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 intoMaybe
.- See Also:
ReduceLeft
,FoldRight
-
-
Field Summary
Fields Modifier and Type Field Description private static ReduceRight<?>
INSTANCE
-
Constructor Summary
Constructors Modifier Constructor Description private
ReduceRight()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Maybe<A>
checkedApply(Fn2<? super A,? super A,? extends A> fn, java.lang.Iterable<A> as)
static <A> ReduceRight<A>
reduceRight()
static <A> Fn1<java.lang.Iterable<A>,Maybe<A>>
reduceRight(Fn2<? super A,? super A,? extends A> fn)
static <A> Maybe<A>
reduceRight(Fn2<? super A,? super A,? extends A> fn, java.lang.Iterable<A> as)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.jnape.palatable.lambda.functions.Fn1
andThen, carry, cartesian, censor, choose, cocartesian, diMap, diMapR, discardL, flatMap, fmap, lazyZip, listens, local, pure, self, thunk, toFunction, trampolineM, zip, zip
-
-
-
-
Field Detail
-
INSTANCE
private static final ReduceRight<?> INSTANCE
-
-
Method Detail
-
checkedApply
public final Maybe<A> checkedApply(Fn2<? super A,? super A,? extends A> fn, java.lang.Iterable<A> as)
-
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)
-
-