A
- The Iterable element typeB
- The accumulation typepublic final class FoldLeft<A,B> extends Object implements Fn3<Fn2<? super B,? super A,? extends B>,B,Iterable<A>,B>
Iterable
of A
s, a starting value B
, and a
Fn2
<B, A, B>
, iteratively accumulate over the Iterable
, ultimately returning
a final B
value. If the Iterable
is empty, just return the starting B
value.
Note that, as the name implies, this function accumulates from left to right, such that foldLeft(f, 0,
asList(1, 2, 3, 4, 5))
is evaluated as f(f(f(f(f(0, 1), 2), 3), 4), 5)
.
For more information, read about Catamorphisms.
FoldRight
Modifier and Type | Method and Description |
---|---|
B |
checkedApply(Fn2<? super B,? super A,? extends B> fn,
B acc,
Iterable<A> as) |
static <A,B> FoldLeft<A,B> |
foldLeft() |
static <A,B> Fn2<B,Iterable<A>,B> |
foldLeft(Fn2<? super B,? super A,? extends B> fn) |
static <A,B> Fn1<Iterable<A>,B> |
foldLeft(Fn2<? super B,? super A,? extends B> fn,
B acc) |
static <A,B> B |
foldLeft(Fn2<? super B,? super A,? extends B> fn,
B acc,
Iterable<A> as) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
apply, apply, apply, checkedApply, compose, contraMap, diMapL, discardR, flip, fn3, fn3, fn3, uncurry, widen
checkedApply, curried, curry, fn2, fromBiFunction, toBiFunction