listFW.visitor
Class FoldL<T,P>
java.lang.Object
listFW.visitor.FoldL<T,P>
- All Implemented Interfaces:
- IListAlgo<T,P,P>
public class FoldL<T,P>
- extends java.lang.Object
- implements IListAlgo<T,P,P>
Folds a list, starting at the left side.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
_f
private ILambda2<P,T,P> _f
FoldL
public FoldL(ILambda2<P,T,P> f)
- Constructor for a FoldL algorithm.
- Parameters:
f - a binary ILambda, i.e. one that takes two parameters as varargs.
emptyCase
public P emptyCase(IMTList<? extends T> h,
P... b)
- Empty case. Return the initial value.
- Specified by:
emptyCase in interface IListAlgo<T,P,P>
- Parameters:
b - b[0] is the initial value.
- Returns:
- initial value
nonEmptyCase
public P nonEmptyCase(INEList<? extends T> h,
P... b)
- Non-empty case. Apply lambda to initial value and first, and recur.
- Specified by:
nonEmptyCase in interface IListAlgo<T,P,P>
- Parameters:
b - b[0] is the initial value.
- Returns:
- result of folding