java.lang.Object
com.jnape.palatable.lambda.functions.builtin.fn2.ReduceLeft<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<Iterable<A>,Maybe<A>>>, Fn2<Fn2<? super A,? super A,? extends A>,Iterable<A>,Maybe<A>>, Applicative<Fn1<Iterable<A>,Maybe<A>>,Fn1<Fn2<? super A,? super A,? extends A>,?>>, Cartesian<Fn2<? super A,? super A,? extends A>,Fn1<Iterable<A>,Maybe<A>>,Fn1<?,?>>, Cocartesian<Fn2<? super A,? super A,? extends A>,Fn1<Iterable<A>,Maybe<A>>,Fn1<?,?>>, Contravariant<Fn2<? super A,? super A,? extends A>,Profunctor<?,Fn1<Iterable<A>,Maybe<A>>,Fn1<?,?>>>, Functor<Fn1<Iterable<A>,Maybe<A>>,Fn1<Fn2<? super A,? super A,? extends A>,?>>, Profunctor<Fn2<? super A,? super A,? extends A>,Fn1<Iterable<A>,Maybe<A>>,Fn1<?,?>>, Monad<Fn1<Iterable<A>,Maybe<A>>,Fn1<Fn2<? super A,? super A,? extends A>,?>>, MonadReader<Fn2<? super A,? super A,? extends A>,Fn1<Iterable<A>,Maybe<A>>,Fn1<Fn2<? super A,? super A,? extends A>,?>>, MonadRec<Fn1<Iterable<A>,Maybe<A>>,Fn1<Fn2<? super A,? super A,? extends A>,?>>, MonadWriter<Fn2<? super A,? super A,? extends A>,Fn1<Iterable<A>,Maybe<A>>,Fn1<Fn2<? super A,? super A,? extends A>,?>>

public final class ReduceLeft<A> extends Object implements Fn2<Fn2<? super A,? super A,? extends A>,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 left fold over the Iterable where the head element is the starting accumulation value and the result is lifted into Maybe.

See Also:
  • Field Details

    • INSTANCE

      private static final ReduceLeft<?> INSTANCE
  • Constructor Details

    • ReduceLeft

      private ReduceLeft()
  • Method Details