listFW.visitor
Class FoldR<T,P>

java.lang.Object
  extended by listFW.visitor.FoldR<T,P>
All Implemented Interfaces:
IListAlgo<T,P,P>

public class FoldR<T,P>
extends java.lang.Object
implements IListAlgo<T,P,P>

Folds a list, starting at the right side.


Field Summary
private   _f
           
 
Constructor Summary
FoldR( f)
          Constructor for a FoldR algorithm.
 
Method Summary
 P emptyCase(IMTList<? extends T> h, P... b)
          Empty case.
 P nonEmptyCase(INEList<? extends T> h, P... b)
          Non-empty case.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_f

private  _f
Constructor Detail

FoldR

public FoldR( f)
Constructor for a FoldR algorithm.

Parameters:
f - a binary ILambda, i.e. one that takes two parameters as varargs.
Method Detail

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