public class SumAlgo implements IFunAlgo { private static SumAlgo _instance = new SumAlgo (); private SumAlgo () { } public static SumAlgo Singleton () { return _instance; } public Object forEmpty (EmptyFW list, Object input) { return new Integer (0); } public Object forCons (ConsFW list, Object input) { Integer carInt = list.car (); Integer tailSumInt = (Integer)list.cdr ().execute (this, null); return new Integer ( carInt.intValue () + tailSumInt.intValue ()); } }